4thSpace 4thSpace - 3 months ago 20
C# Question

How to update checkbox via event?

In a WPF app, I have a DataGrid with a checkbox column. At some point, I loop through data and determine that some rows in the DataGrid need to be checked.

What approach can be use so each grid row is updated as the above looping determines the row should be checked. I'd like the checks to appear one by one as the user waits. I believe this means the back end thread can't block.

Answer

The checkbox needs to be bound to a Boolean via TwoWay binding which reports a NotifyPropertyChanged type notification. When that Boolean is changed either in the GUI or in the backend, the notification will change it on the screen.

Comments