Databindings don't seem to refresh
Solution 1:
Implement INotifyPropertyChanged on your class. If you have many classes that need this interface, I often find it helpful to use a base class like the following.
public abstract class ObservableObject : INotifyPropertyChanged
{
protected ObservableObject( )
{
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged( PropertyChangedEventArgs e )
{
var handler = PropertyChanged;
if ( handler != null ) {
handler( this, e );
}
}
protected void OnPropertyChanged( string propertyName )
{
OnPropertyChanged( new PropertyChangedEventArgs( propertyName ) );
}
}
Then you just have to make sure you raise the PropertyChanged event whenever a property value changes. For example:
public class Person : ObservableObject {
private string name;
public string Name {
get {
return name;
}
set {
if ( value != name ) {
name = value;
OnPropertyChanged("Name");
}
}
}
}