Binding c# xaml element depending on value
I have <TextBlock Text="{Binding TexT}" Style="{StaticResource PhoneTextNormalStyle}"/>
Also have {Binding Read_State} (bool Read_State)
How I can change color of TextBlock to bl开发者_StackOverflowue if Read_State==false?
You need to use a DataTrigger in a style for your TextBlock:
<TextBlock ...>
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Read_State}" Value="False">
<Setter Property="Background" Value="Blue" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
I would rename your PhoneTextNormalStyle to PhoneTextStyle and add the trigger to that style which would then handle both (or all states if there are more conditions).
精彩评论