如何更改工具栏中的按钮文本颜色?(How to change button text colour in a Toolbar?)

编程入门 行业动态 更新时间:2024-10-27 04:25:00
如何更改工具栏中的按钮文本颜色?(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

更多推荐

本文发布于:2023-08-02 17:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1378718.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:栏中   按钮   如何更改   文本   颜色

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!