【发布时间】:2011-01-02 07:55:12
【问题描述】:
<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> 中写下这段代码。但它不运行。我该怎么做?
【问题讨论】:
-
在 Application.Resources 中编写此代码时会发生什么。你得到一个编译器错误吗?如果是这样,你能告诉我们错误是什么吗?
-
那里,格式化你的代码。为了将来参考,在每行或代码之前放置四个空格,对于内联代码
like this,用反引号将其括起来(asdasd)。现在,问题是,当您将其放入 Application.Resources 时会发生什么?