【发布时间】:2022-01-06 08:25:57
【问题描述】:
我正在尝试通过绑定更改按钮的样式以及按钮中包含的文本块的样式,但没有成功。 我想得到这样的东西:
我想根据绑定改变TextBlock前景色和Button BorderThickness。
这是我的代码:
<Button Name="WeldHistory"
Margin="20,0,20,0"
VerticalAlignment="Stretch"
Height="auto"
Background="{x:Null}"
BorderBrush="{StaticResource RedPolysoudeNormalBrush}"
BorderThickness="0 0 0 3"
Command="{Binding ScreenWeldHistoryCommand}" >
<Button.ContentTemplate>
<DataTemplate>
<TextBlock Text="{x:Static lang:UI_Text.SCREEN_PROGRAM_LIBRARY}" Typography.Capitals="AllSmallCaps" Typography.CapitalSpacing="True">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsWeldHistoryActive}" Value="False">
<Setter Property="Foreground" Value="red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</DataTemplate>
</Button.ContentTemplate>
【问题讨论】: