silent bug if u forget to implement INotifyPropertyChanged

public int PortNumber{
    return _portNumber;
    if (_portNumber != value){
      _portNumber = value;

If host class Agent implements INotifyPropertyChanged, then the wiring works as follows
#1) users click a “++” button
#4) event handler increments PortNumber and saves it via the setter
#6) setter fires prop changed event
#9) xaml binding system queries PortNumber property via getter — you can see this in a debugger

Now things break if you don’t implement INPC. Xaml binding doesn’t call the getter (#9) and won’t display new value, even though
– event firing still happens (#6),
– xaml won’t complain either

I think xaml will still bind to this Agent object, but won’t treat Agent as a “Notifying source”, so the binding system will ignore the event — the invitation to re-query the VM for updates.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s