There is a problem in your NotifyPropertyChangedHandler.Invoke
method code:
Your Code
I have added some comments to describe what the problem is with this code.
public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
{
var npcAttribute = getNotifyPropertyChangedAttributeForSetter(input) as NotifyPropertyChangedAttribute;
if (npcAttribute != null)
{
if (npcAttribute.TimingOption == PropertyChangedTiming.Always||
shouldRaiseEvent(input))
{
// You are raising property changed event here,
// however the value of the property is not changed until getNext()(input, getNext) called
// So, WPF will re-read the same "old" value and you don't see anything updated on the screen
raiseEvent(input);
}
}
// Property value is updated here!!!
return getNext()(input, getNext);
}
Change that code to something like:
public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
{
var temp = false;
var npcAttribute = getNotifyPropertyChangedAttributeForSetter(input) as NotifyPropertyChangedAttribute;
if (npcAttribute != null)
{
if (npcAttribute.TimingOption == PropertyChangedTiming.Always||
shouldRaiseEvent(input))
{
temp = true;
}
}
var returnValue = getNext()(input, getNext); // Changing the value here
if (temp) raiseEvent(input); // Raising property changed event, if necessary
return returnValue;
}
I have tested this code and it works. Hope this helps!