I have a DataGrid with a DataGridCheckBoxColumn and others. The DataGrid ItemSource is mapped to a ObservableCollection that contains rows of Tasks. The Task class includes properties like "ID", "IsScheduled", "IsScheduled_Date", "IsScheduled_EditorID", Etc. I am trying to figure how to make the one DataGridCheckBoxColumn field (IsScheduled) also save the date (IsScheduled_Date) and who made the change (IsScheduled_EditorID) when checked.
(1) I have tried to make this save the extra data using multibinding, but my efforts have so far failed. You can see follow my progress with solving a similar issue Here.
(2) I have tried having the DataGrid CellEditEnding event save the extra data but it ended up committing the extra data before the IsScheduled data was committed and caused troubles whenever the row and/or cell edit was canceled.
(3) I have tried listening to the property change event in my Task class and assigning the additional changes there. This seemed to work fine until I realized that when the data was first loaded it cause a change event that overwrote any earlier changes.
Added Information
The Task class is an Entity Framework Class that was generated from a DB. I was listening to the OnIscheduledChanged event and making the necessary changes because when I did it in the generated class it was always overwritten.
More Info
There seems to be some confusion about the Task class. As I stated it is generated by the Entity Framework and a breakpoint shows the setters being called on load… Overwriting the change. Not to mention any custom code being overwritten everytime the code regenerates.
/// <summary> /// No Metadata Documentation available. /// </summary> [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)] [DataMemberAttribute()] public global::System.Boolean IsScheduled { get { return _IsScheduled; } set { OnIsScheduledChanging(value); ReportPropertyChanging("IsScheduled"); _IsScheduled = StructuralObject.SetValidValue(value); ReportPropertyChanged("IsScheduled"); OnIsScheduledChanged(); } } private global::System.Boolean _IsScheduled; partial void OnIsScheduledChanging(global::System.Boolean value); partial void OnIsScheduledChanged();
Any Ideas?
I ended up creating a ViewModel class for the entity model that exposed the same property. I bound the DataGrid ItemSource to a list of the wrapped Task Models (e.g. below). [Obviously this is quick example class to show the property and would need property notification to work properly]