【问题标题】:Silverlight DataGrid: Changing Background Color Dynamically After It Is LoadedSilverlight DataGrid:加载后动态更改背景颜色
【发布时间】:2011-09-10 01:47:36
【问题描述】:

情况如下:

1) 我有带有数字的单元格。如果数字小于 x,则将其着色为绿色。如果数字大于 y,则显示为红色。

2) 我使用转换器在加载数据网格时设置颜色。这很好用。

3) 我从 C# 更改数据源中的数字值,并且该值在数据网格上更新(如果可见)。

4) 不幸的是,转换器没有触发以设置正确的颜色。如果我手动编辑数据网格中的单元格,转换器就会触发。

我可以在数据网格中找到单元格并重置颜色,但这会导致更改后出现滚动问题(如预期的那样)。

提前致谢,

迈克

【问题讨论】:

    标签: silverlight datagrid converter


    【解决方案1】:

    我相信您有几个选择,例如:

    1)  invoking a property changed notification when the color is changed (for the property your converter is converting).
    2)  invoking UpdateLayout()
    3)  detaching and reattaching the items source
    4)  saving scroll position, performing "find the cell in the datagrid and reset the color ", and then invoking a scroll to the saved scroll position.
    

    如果这些不起作用,请告诉我您是使用 PagedCollectionView 作为您的 ItemsSource 还是 ObservableCollection。

    【讨论】:

      猜你喜欢
      • 2010-09-24
      • 2014-04-05
      • 2014-06-06
      • 2013-09-03
      • 1970-01-01
      • 2011-12-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多