Whenever I create a new class that will be view in WPF and have the values change in the background I add the following.
The INotifyPropertyChanged give a hook for the WPF to pull on which then then link to the PropertyChanged event handle.
Each property then has to have a changed event sent to it, an empty property name will notify WPF that all properties have changed.
public class DataLink : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
private string _Field1;
public string Field1
{
get { return this._Field1; }
set { this._Field1 = value; this.SendPropertyChanged("Field1"); }
}
}
first test
second test
third test