【问题标题】:How to change button text colour in a Toolbar?如何更改工具栏中的按钮文本颜色?
【发布时间】:2012-04-18 11:19:52
【问题描述】:

是否可以更改Button 文本的颜色,其中按钮存在于工具栏中?

我在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>

【问题讨论】:

标签: wpf xaml button colors toolbar


【解决方案1】:

你可以通过调用外部样式表来做到这一点

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-07
    • 1970-01-01
    • 1970-01-01
    • 2016-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多