I have a textblock that is bound to an object. This object I have overridden ToString to return a combination of 2 other properties. How can I notify that the ToString value has been changed when one of the property values is updated?
Unfortunately I cannot change the binding to the ToString value as this is within a 3rd party control so really need to be able to notify directly.
Hopefully the class definition below will clarify what I mean:
public class Person : INotifyPropertyChanged
{
private string firstname;
public string Firstname
{
get { return firstname; }
set
{
firstname = value;
OnPropertyChanged("Firstname");
}
}
private string surname;
public string Surname
{
get { return surname; }
set
{
surname = value;
OnPropertyChanged("Surname");
}
}
public override string ToString()
{
return string.Format("{0}, {1}", surname, firstname);
}
}