<Window.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="FontFamily" Value="Times New Roman" />
<Setter Property="FontSize" Value="30" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Background" Value="#FFCA5132" />
</Style>
</Window.Resources>
此上面的代码看起来像是将WPF样式应用于特定窗口中的所有按钮的正确选择。但我想将这种风格应用于我的程序中的所有按钮。 我想我需要在<Application.Resources></Application.Resources>
中写下这段代码。但它不运行。我怎样才能做到这一点?如何将WPF样式应用于特定类型的所有元素?
当你写这Application.Resources会发生什么。你有编译器错误吗?如果是这样,你能告诉我们错误是什么。 – Tarydon 2010-01-07 02:11:21
那里,格式化你的代码。为了将来的参考,在每行或每行代码前放置四个空格,并且对于内嵌代码''this''用反引号(''asdasd'')包围它。现在,对于这个问题,当你把它放在Application.Resources中会发生什么? – 2010-01-07 02:11:39