When the value of a property is changed it should notify the bound objects that the property value has changed. You can do that by implementing changed event.
C#
public class Client
{
private string name;
public event EventHandler NameChanged;
public string Name
{
get
{
return this.Name;
}
set
{
if ( this.name == value )
return;
this.name = value;
this.OnNameChanged( EventArgs.Empty );
}
}
protected virtual void OnNameChanged( EventArgs e )
{
if ( this.NameChanged != null )
this.NameChanged( this, e );
}
}
Note that the value is changed only if the new value is different. Thus we prevent the firing of the NameChanged event when the actual value is not changed.
Alternative way is to implement INotifyPropertyChanged interface.
That's it!