In my XAML code, I have a binding to the current dataitem like this:
Background="{Binding Path=., Converter={StaticResource ResourceKey=kBackground}}"
My converter uses several properties of the dataitem to determine the background. When any of those properties change, the background color could change. I want to send a notification to the target so that the background will change appropriately. My question is that I don’t know how to send such a notification when the binding path is “.”.
If my converter uses PropertyA and PropertyB, calling:
PropertyChanged(this, new PropertyChangedEventArgs("PropertyA"))
and/or
PropertyChanged(this, new PropertyChangedEventArgs("PropertyB"))
doesn’t trigger the binding. I tried calling this:
PropertyChanged(this, new PropertyChangedEventArgs("."))
but it didn’t trigger the binding either.
How do I call PropertyChanged in such a way that my “Path=.” bindings get notifications that they need to update?
This may be a duplicate question, but I couldn’t find one. I don’t know the terminology very well.
Try using an IMultiValueConverter instead, and passing it the properties it needs
This should get re-evaluated anytime a PropertyChange notification is raised for either
PropertyAorPropertyBThe alternative using your current binding syntax would be to raise a
PropertyChangenotification of your parent data item anytimePropertyAorPropertyBchanges.For example, assuming your current data item is
SomeObject: