views:

367

answers:

1

Hi, I am currently playing around with WPF and the WPF toolkit which contains a WindowsForms-style DataGrid.

I have bound a list of custom objects to the grid as ItemsSource. These objects contain two boolean properties which are editable using the datagrid. Synchronising back into my list works fine using the build-in databinding model but I have to call another method if one of the CheckBox values changed to serialise the object back in XML. Unfortunately I can't do this caching within my data class itself since it doesn't know its cache provider.

Therefore I need an event on the DataGrid which fires right after a checkbox value has changed.

I have already inherited a AutoCommitCheckBoxColumn class from the original DataGridCheckBoxColumn which overrides the method GenerateEditingElement(DataGridCell cell, object dataItem) and also the checkbox_(Un-)Checked handlers.

Obviously I can't and don't want to call the caching method from here either - it needs to be done in the Window class where the DataGrid resides.

So - I just can't find a proper event for this: The MouseButton.. events only fire when the outer cell space and not the inner checkbox in a cell is clicked. CellEditEnding would work but is only fired if one selects another cell after (un-)checking a checkbox. SourceUpdated doesn't fire at all.

Can anyone help me here with a fitting event? Or can I somehow safely trigger an event on the datagrid from my AutoCommitCheckBoxColumn class?

Thank you very much in advance!

A: 

Have you considered using WPF Data triggers?

See here for more info: http://en.csharp-online.net/WPF_Styles_and_Control_Templates—Data_Triggers

Tony
I resolved the issue using the INotifyPropertyChanged event: http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspxThanks anyways.
SimonW