2012-04-18 85 views
1

是否可以更改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> 
+0

我找到了答案: http://stackoverflow.com/questions/3701263/c-sharp-wpf-how-to-modify-the-toolbar-buttonstylekey-style – DaveDev 2012-04-18 11:27:44

回答

0

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

相关问题