I'm trying to define a DataTrigger
for an Image
element so that it shows a connected/disconnected image. I keep getting an Invalid PropertyDescriptor
message. Any ideas?
<Image>
<Image.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static my:Server.Instance}, Path=Connected, Mode=OneWay}"
Value="True">
<Setter Property="Source"
Value="serverconnected.png"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
I just changed Property="Source" to Property="Image.Source" and it's working. Thanks everyone
Add a BitmapImage to your resources like so:
<BitmapImage x:Key="serverConnected" UriSource="serverconnected.png" />
And change your existing code to refer to it:
<Image>
<Image.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static my:Server.Instance}, Path=Connected, Mode=OneWay}"
Value="True">
<Setter Property="Source"
Value="{StaticResource serverConnected}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With