【问题标题】:different image as tooltip for different rows in a datagrid in wpfwpf中数据网格中不同行的不同图像作为工具提示
【发布时间】:2009-11-28 02:46:35
【问题描述】:

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

但这显示了整个数据网格的相同图像,无论我将鼠标指针放在哪一行。如何使该图像对于数据网格中填充的每一行都不同。请帮忙。提前致谢。

【问题讨论】:

    标签: wpf datagrid tooltip wpfdatagrid


    【解决方案1】:

    看起来您正在为整个数据网格设置工具提示:

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

    您需要对每一行执行此操作,方法是手动循环,或者挂钩到发生数据绑定时触发的某个事件。在 VS 2010 Beta 2 中,WPF DataGrid 有一个 LoadingRow 事件,您可以使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-04
      • 2022-11-26
      • 1970-01-01
      • 2012-05-15
      相关资源
      最近更新 更多