2009-11-26 69 views
0

我正在wpf中填充数据网格中的某些东西。 我需要为数据网格中的每一行,当我指向我的鼠标,工具提示应该是可见的包含图像。这个图像对于数据网格的每一行都是不同的。我如何去做。我已经能够做到这一点:不同的图像作为提示wpf中的数据网格中不同行的工具提示

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); 

但是这显示了相同的形象,为整个数据网格,无论什么排的我把我的鼠标指针上。我怎样才能使这个图像不同填充在数据网格中的每一行。请帮忙。提前致谢。

回答

0

它看起来像你设置了整个数据网格的工具提示:

ToolTipService.SetPlacement(dgAssortment,(我假设dgAssortment是你的数据网格)。

您需要为每行执行此操作,无论是通过手动循环还是挂钩发生数据绑定时触发的某个事件。在VS 2010 Beta 2中,WPF DataGrid有一个您可能可以使用的LoadingRow事件。

相关问题