【发布时间】:2014-08-26 09:03:38
【问题描述】:
我创建了一个名为 Dictionary1.xaml 的 ResourceDictionary,代码如下:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type Window}">
<Setter Property="Background" Value="Red">
</Setter>
</Style>
我在 App.xaml 或 MainWindow.xaml 中这样引用它:
<Application.Resources>
<ResourceDictionary Source="Dictionary1.xaml" />
</Application.Resources>
<Window.Resources>
<ResourceDictionary Source="Dictionary1.xaml" />
</Window.Resources>
在视图设计器中,窗口的背景变为红色,但是当应用程序运行时,它的背景是默认的(白色),为什么?怎么办?
【问题讨论】: