0
我將圖片路徑保存到datagrid行,並且我想在鼠標懸停在datagrid行上時顯示彈出圖像。DataGrid Popup圖像
像這樣:
這是我的XAML代碼:
<DataGrid Name="DG_selected_pictures" AutoGenerateColumns="False" Margin="8,74,8,-113.8" IsReadOnly="True">
<DataGrid.Columns >
<DataGridTextColumn Binding="{Binding Path=Picture}" MinWidth="485" />
</DataGrid.Columns>
</DataGrid>
背後的C#代碼:
private void BT_select_pictures_click(object sender, RoutedEventArgs e)
{
var picture_list = new ObservableCollection<DataObject>();
Microsoft.Win32.OpenFileDialog openfile = new Microsoft.Win32.OpenFileDialog();
//string filter = "Picture files "(*.jpg)|*.jpg|All files (*.*)|*.*";
openfile.Filter = "Picture files (*.jpg)|*.jpg|All files (*.*)|*.*";
openfile.Multiselect = true;
if (openfile.ShowDialog() == true)
{
int index = openfile.FileName.LastIndexOf("\\") + 1;
int lastindex = openfile.FileName.Length - 1;
string folderPath = openfile.FileName;
folderPath = folderPath.Remove(index, folderPath.Length - index);
TB_selected_files_folder.Text = folderPath;
}
foreach (String picture in openfile.FileNames)
{
i++;
picture_list.Add(new DataObject() { Picture = picture });
selected_pictures.Add(picture);
}
LB_selected_pictures_count.Content = Convert.ToString(i) + " db";
this.DG_selected_pictures.ItemsSource = picture_list; // This is the datagrid
}
的prolem是,我不知道如何我可以做嗎。工具提示或彈出?語法是什麼?
感謝和抱歉我的英語不好。
<DataGridTextColumn Binding="{Binding Path=Picture}" MinWidth="485">
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="ToolTip">
<Setter.Value>
<Image Source="{Binding Path=Picture}"/>
</Setter.Value>
</Setter>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
謝謝!!!我正在考慮這個! – Haldyr