different image as tooltip for different rows in a datagrid in wpf
I am doing something in wpf where in a datagrid is populated. I need that for each row in the datagrid, when i point my mouse, a tooltip should be visible containing an image. And this image will be different for each row of the datagrid. How do i go about it. I have been able to do this:
Image img = new Image();
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = new Uri(Directory.GetCurrentDirectory()+ "\\Kartik.JPG");
bmp.DecodePixelHeight=200;
bmp.DecodePixelWidth=200;
bmp.EndInit();
img.Source=bmp;
ToolTipService.SetPlacement(dgAssortment, System.Windows.Controls.Primitives.PlacementMode.Center);
ToolTipService.SetToolTip(dgAssortment, img);
ToolTipService.SetShowDuration(dgAssortment, 99999999);
But this shows the same image for the entire datagrid, irrespective of what row i keep my mouse pointer on. How can I make this image different for each row populated in the datagrid. Please h开发者_开发百科elp. Thanks in advance.
It looks like you're setting the tooltip for the entire datagrid:
ToolTipService.SetPlacement(dgAssortment,
(I'm assuming dgAssortment is your datagrid).
You'll need to do this for each row, either by looping through manually, or hooking into some event that's fired when data binding occurs. In VS 2010 Beta 2, the WPF DataGrid has a LoadingRow event that you might be able to use.
精彩评论