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