I want to set a cell in my WPF DataGrid on a button click.
I fill a WPF DataGrid like this:
myDataGrid.ItemsSource = GetMyList();
The DataGrid is set to autoGenerateColumns. I get my list using a mySql select.
The objects in my list implement the INotifyPropertyChanged interface.
On my button click I do this:
MyObject o = (MyObject)myDataGrid.SelectedItem;
o.Checkin = DateTime.Now; //set date on button click is what i want
The data is set but the DataGrid doesn’t update its view. Why?
Edited:
I implement the INotifyPropertyChanged interface like this:
private void NotifyPropertyChanged(String info) {
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public DateTime Checkin {
get {return this.checkin;}
set {
this.checkin= value;
NotifyPropertyChanged("Checkin");
}
}
}
this did the trick: