Silverlight does not feature DataTriggers, so in this case... what might be the best way to conditionally set the fontweight of an item to a boolean?
For example... the following is not possible in Silverlight.
<TextBlock Text="{Binding Text}">
<TextBlock.Triggers>
<DataTrigger Binding="{Binding IsDefault}" Value="True">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsDefault}" Value="False">
<Setter Property="FontWeight" Value="Normal"/>
</DataTrigger>
</TextBlock.Triggers>
</TextBlock>
Thanks!
You could implement a IValueConverter that converts a bool to a FontWeight, and use it as the binding's converter :
<UserControl.Resources>
<local:BoolToFontWeightConverter x:Key="boolToFontWeight"/>
</UserControl.Resources>
...
<TextBlock Text="{Binding Text}" FontWeight="{Binding IsDefault, Converter={StaticResource boolToFontWeight}}">
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