【发布时间】:2013-08-02 17:55:49
【问题描述】:
我尝试在 XAML 中为 WPF Window 设置 Style。我可以在 VS Designer 中看到我的更改,但是当我运行应用程序时,它总是会得到默认的 Style。
不工作:
<Style TargetType="Window">
<Setter Property="Background" Value="Red"/>
</Style>
如果我给 Style 加上 Key 并将 Style 应用到 Window 那么它就可以工作了。
工作:
<Style x:Key="window" TargetType="Window">
<Setter Property="Background" Value="Red"/>
</Style>
有什么理由需要为Style 提供Window 的密钥?
谁能解释一下是怎么回事?
【问题讨论】: