【问题标题】:Color cells in WPF DataGrid dynamically动态为 WPF DataGrid 中的单元格着色
【发布时间】:2011-08-07 17:29:47
【问题描述】:

我使用作为搜索结果的动态数据填充 WPF DataGrid 的内容。现在我想突出显示 DataGrid 的那些单元格,这些单元格包含在搜索期间匹配的数据。 here 给出了一些关于如何实现这一点的提示。这个问题有更优雅的解决方案吗?

【问题讨论】:

    标签: c# wpf datagrid colors cell


    【解决方案1】:

    绑定到数据是最好的方法。但是,如果数据没有适当的值,则需要使用转换器(如示例中所示)。

    如果您想要更优雅的东西,我会在数据中添加一个转换并改为绑定到该属性

    说喜欢:

      public int RealProperty { .... }
    
      public SystemColors.AppWorkspaceColor Colour { return manglefromInt(RealProperty); }
    

    【讨论】:

    • 您能详细说明一下吗?我不明白你的例子的颜色部分。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    • 2020-04-18
    • 2011-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多