开发者

Color cells in WPF DataGrid dynamically

开发者 https://www.devze.com 2023-02-25 08:41 出处:网络
I populate t开发者_如何学Gohe contents of a WPF DataGrid with dynamic data that is the result of a search. Now I would like to highlight those cells of the DataGrid, that contain data which was matche

I populate t开发者_如何学Gohe contents of a WPF DataGrid with dynamic data that is the result of a search. Now I would like to highlight those cells of the DataGrid, that contain data which was matched during the search. Some hints about how this could be achieved are given here. Is there more elegant solution to this problem?


Binding to the data is the best way. However if the data doesn't have the appropriate values then a converter needs to be employed (as in the examples).

if you want something more elegant, I'd add a conversion within the data and bind to that property instead

say like :

  public int RealProperty { .... }

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

精彩评论

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

关注公众号