如何将Application.xaml中定义的样式应用于特定窗口中的所有文本框?我不想Style="{StaticResource MyStyle}"用它们中的每一个打字,因为它们确实有几十种.这是WPF + VS2010.
sa_*_*213 39
然后只需添加Style到您App.Xaml或您的Theme.xaml(如果您有)或甚至Window.Resources是您只有1 Window,只要确保您没有设置x:Key
例:
这将适用于所有TextBoxes(没有x:键)
<Style TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="Red" />
</Style>
Run Code Online (Sandbox Code Playgroud)
TextBoxes必须Style="{StaticResource MyStyle}"使用它:
<Style x:Key="MyStyle" TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="Red" />
</Style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15940 次 |
| 最近记录: |