Hi,
I am using the hierarchy feature of the data grid. My data consist of two custom objects one composed of the other.
(My actual classes invoke the PropertyChanged event. I did not show the full setters here for simplicity.)
I am setting a BindingList<MyClassA> as the data source for the grid view. I understand from this post here that you must handle the change event on the data grid when using the hierarchy view. I did this below:
This works for updating the data model when changes are made to the UI. How do I see changes reflected in the UI when changes are made to the model?
I am using the hierarchy feature of the data grid. My data consist of two custom objects one composed of the other.
class MyClassA : INotifyPropertyChanged{ String Porperty1 {get; set;} BindiingList<MyClassB> Items {get; set;} //...}class MyClassB : INotifyPropertyChanged{ String Property1 {get; set;} int Property2{ get; set;} //...}I am setting a BindingList<MyClassA> as the data source for the grid view. I understand from this post here that you must handle the change event on the data grid when using the hierarchy view. I did this below:
private void dataGrid_CellValueChanged(object sender, GridViewCellEventArgs e) { //if the column is from the child view we must handle the change to the data model directly if(e.Column.OwnerTemplate == gridViewTemplate1) { var b = e.Row.DataBoundItem as MyClassB; var property = typeof(MyClassB).GetProperty(e.Column.FieldName); property.SetValue(b, e.Value, null); } }This works for updating the data model when changes are made to the UI. How do I see changes reflected in the UI when changes are made to the model?
