Question

I have an image with source set by a ValueConverter:

<Image Source="{Binding Converter={StaticResource siConv}}" Width="16" Height="16"/>

When the bound object raises a PropertyChanged event (from INotifyPropertyChanged), the image does not change. I assume it is because WPF doesn't know what fields the converter looks at.

How do I tell WPF to rebind/rerun this converter when a certain property changes?

Was it helpful?

Solution

The answer here was to use data triggers, not value converters. The trigger is bound directly to the property, and picks up the propertychanged event. Also, saves writing a bunch of one-time value converters.

OTHER TIPS

And if you really intent on writing a ValueConverter, may be use a MultiValueConverter with all the values that you want the WPF framework to monitor. Any changes to those values, and the framework would update the value it is binded to.

the Path is important:

<Image Source="{Binding Converter={StaticResource siConv}, ConverterParameter=yourproperty, Path=yourproperty, UpdateSourceTrigger=PropertyChanged}"  Width="16" Height="16"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top