开发者

Updating the styling of a WPF DataGrid and forcing a refresh

开发者 https://www.devze.com 2023-01-08 04:11 出处:网络
I\'m using an IValueConverter in conjunction with DataTriggers (all in code, not XAML) to implement conditional styling for a WPF DataGrid (from codeplex.com).I have all the code in place, but when I

I'm using an IValueConverter in conjunction with DataTriggers (all in code, not XAML) to implement conditional styling for a WPF DataGrid (from codeplex.com). I have all the code in place, but when I update the styling (after obtaining some values from form elements) the datagrid does not update the display of the elements. I have to manually call this.dataGrid.InvalidateVisual() and then scroll down and back up to get the grid elements to refresh themselves. Is there a better way of doing things ?

I've tried using this.dataGrid.Items.Refresh(), but this causes a rebinding of the grid data (of which there may be thousands of rows) which in turn causes a huge jump in my program's memory consumption. Does anybody have any idea how to manually force a redrawing of the WPF data grid ? I've also tried doing this.dataGrid.Dispatcher.Invoke((Action)(() => {})); to try to force the dispatcher to perform an operation that will result in a redraw, but to no effect. Any suggestions are开发者_开发百科 appreciated.

0

精彩评论

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