如何更改工具栏中的按钮文本颜色?(How to change button text colour in a Toolbar?)
是否可以更改Button文本的颜色,按钮存在于工具栏中?
我在app.xaml尝试了以下app.xaml
<Style TargetType="{x:Type Toolbar}"> <!-- this changes the background colour --> <Setter Property="Background" Value="AliceBlue"/> <!-- works --> <Setter Property="Foreground" Value="Red"/> <!-- doesn't work --> </Style>我试过了
<Style TargetType="{x:Type Button}"> <!-- this changes both colours --> <Setter Property="Background" Value="AliceBlue"/> <!-- works --> <Setter Property="Foreground" Value="Red"/> <!-- work --> </Style>工具栏定义为:
<ToolBarTray Background="White" Width="Auto"> <ToolBar UseLayoutRounding="True" > <Button Content="Options" Name="btnOptionsSettings" Click="btnOptionsSettings_Click" ></Button> <Button Content="Timer" Name="btnTimerSettings" Click="btnTimerSettings_Click" ></Button> <Button Content="Blocks" Name="btnBlocks" Click="btnBlocks_Click" ></Butto </ToolBar> </ToolBarTray>Is it possible to change the colour of Button text, where the button exists in a Toolbar?
I tried the following in app.xaml
<Style TargetType="{x:Type Toolbar}"> <!-- this changes the background colour --> <Setter Property="Background" Value="AliceBlue"/> <!-- works --> <Setter Property="Foreground" Value="Red"/> <!-- doesn't work --> </Style>and I've tried
<Style TargetType="{x:Type Button}"> <!-- this changes both colours --> <Setter Property="Background" Value="AliceBlue"/> <!-- works --> <Setter Property="Foreground" Value="Red"/> <!-- work --> </Style>The toolbar is defined as:
<ToolBarTray Background="White" Width="Auto"> <ToolBar UseLayoutRounding="True" > <Button Content="Options" Name="btnOptionsSettings" Click="btnOptionsSettings_Click" ></Button> <Button Content="Timer" Name="btnTimerSettings" Click="btnTimerSettings_Click" ></Button> <Button Content="Blocks" Name="btnBlocks" Click="btnBlocks_Click" ></Butto </ToolBar> </ToolBarTray>最满意答案
你可以通过调用外部样式表来做到这一点
you can do this by calling external style sheet
更多推荐
发布评论