2013-02-16 73 views

回答

37

然後,只需添加StyleApp.Xaml或您的Theme.xaml(如果有的話),甚至你的Window.Resources如果你只是有1 Window,只要確保你沒有設置x:Key

例子:

這將適用於所有TextBoxes(無X:鍵)

<Style TargetType="{x:Type TextBox}"> 
    <Setter Property="Foreground" Value="Red" /> 
</Style>  

文本框將不得不使用Style="{StaticResource MyStyle}"使用這:

<Style x:Key="MyStyle" TargetType="{x:Type TextBox}"> 
    <Setter Property="Foreground" Value="Red" /> 
</Style>  
+3

這是你希望你沒有問過那些簡單的事情之一。謝謝一堆。 – dotNET 2013-02-16 08:03:23

相關問題