开发者

Silverlight DataGrid: Changing Background Color Dynamically After It Is Loaded

Here is the situation:

1) I have cells with numbers. If the number is less than x, it is colored green. If the number is greater than y, it is colored red.

2) I use a Converter to set the color when the datagrid is loaded. This works fine.

3) I change the number value in my data source from C# and the value is updated on开发者_高级运维 the datagrid (if it is visible).

4) Unfortunately, the converters are not firing to set the proper color. If I manually edit the cell in the datagrid, the converters fire.

I can find the cell in the datagrid and reset the color but that causes issues with scrolling after the change (as expected).

Thanks in advance,

Mike


I believe there are a couple of options available to you, such as:

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.

Should these not work out, let me know if you are using a PagedCollectionView as your ItemsSource or an ObservableCollection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜