views:

106

answers:

1

So I have an object that implements INotifyPropertyChanged, and I have a property that when it changes, it call the PropertyChanged event all right, but when I use a converter like this:

        <Image Grid.Column="0">
      <Image.Source>
       <Binding Path="IsInstrumentStatusOk" UpdateSourceTrigger="PropertyChanged">
        <Binding.Converter>
         <converters:BooleanToImageConverter 
          ImagePathIfFalse="/Images/InstrumentStatusBar/Instrument_Status_Alarm.png"
          ImagePathIfTrue="/Images/InstrumentStatusBar/Instrument_Status_OK.png" />
        </Binding.Converter>
       </Binding>
      </Image.Source>
     </Image>

For some reason it doesn't update it, and it doesn't call the converter. If I use it like normally

Source="{Binding MyProperty, Converter={StaticResource MyConverter}}"

It works, but I don't want to use it like that because I have a bunch of converters that I want to use with different images. Any idea why it doesn't update?

Thanks.

+2  A: 

You're setting UpdateSourceTrigger="PropertyChanged" in your XAML. This means when the target property changes the value should update back to the source. Obviously nothing is ever changing the Image::Source property.

Just remove the UpdateSourceTrigger setting altogether and you should be fine.

Drew Marsh
This didn't do it either, I had to take the Converter and put it in the resource, then reference to it as a StaticResource. It's weird, I have no idea why it wasn't working.
Carlo
That is very strange. There's no reason I can think of that it shouldn't work inline like that.
Drew Marsh
Ok, so I tried it again, this time it worked. Maybe I'm not using something I was using before? No idea. Thanks for the answer.
Carlo