
Learning through teaching
- Processes, standards and quality
- Technologies
- Others
That’s a true story. This conversation between me and a new member of my team happened when I was introducing him to the world of WPF. For the purpose of this text, let’s call him Zenon.
Zenon: hey, bindings ignore private property setters and just use them.
Me: ? – I approach his computer, debug and can’t believe what I see. I return to my computer, create some simple application (because I bet his computer is broken or sth). I can’t believe even more. Strange… Uncle Google. Whew – it was a load off my mind. Error in .NET 4.5! Here are the details:
public class Person
{
private string _name;
public string Name
{
get { return _name; }
private set
{
if (_name == value)
{
return;
}
_name = value;
}
}
}For such a defined class TwoWay Binding respects setter’s privacy and an exception is just thrown – perfectly, but:
public class Person : NotificationObject
{
private string _name;
public string Name
{
get { return _name; }
private set
{
if (_name == value)
{
return;
}
_name = value;
RaisePropertyChanged(...);
}
}
}Here Mr Binding is doing what he wants – error concerns a different Binding interpretation of objects implementing INotifyPropertyChanged (in our case, from Prism) and those which don’t implement them.
Thanks Zenon!

