I have a property that is populated via binding. Color attribute is set the value of Color property
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=Color}"/>
</Rectangle.Fill>
How can I refactor that to the conditional binding like that:
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=SomeBooleanProperty ? #FF0000 : #00FF00 }"/>
</Rectangle.Fill>
Thank you, @Jackson, final code is the following:
<Style TargetType="Rectangle" x:Key="ColorBySuccess">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Success}" Value="True">
<Setter Property="Fill" Value="#00FF00"/>
</DataTrigger>
</Style.Triggers>
</Style>
...
<Rectangle Fill="Green" Style="{StaticResource ColorBySuccess}" .../>
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