任何人都可以帮我解决问题,我正在创建一个自定义窗口并创建了我的Generic.xaml,其中包含以下对新窗口主题的引用
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Cleo.Windows.Ui.Controls.AeroWindow;component/Themes/AdministrationWindow.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
在AdministrationWindow.xml文件中,我添加了以下内容:
<ControlTemplate x:Key="AdministrationWindowStyle" TargetType="{x:Type aeroWindow:AdministrationWindow}">
<Grid Background="Red">
<ContentPresenter />
</Grid>
</ControlTemplate>
<Style TargetType="{x:Type aeroWindow:AdministrationWindow}">
<Setter Property="Template" Value="{DynamicResource AdministrationWindowStyle}" />
</Style>
所以从上面我应该得到一个红色背景窗口,对吧?好吧,我没有,当我运行应用程序时,我得到一个带标题栏和黑色客户区的窗口。
如果我尝试以下操作,那么我会得到正确的结果
<Style TargetType="{x:Type aeroWindow:AdministrationWindow}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type aeroWindow:AdministrationWindow}">
<Grid Background="Red">
<ContentPresenter />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我已经看过很多次使用的第一种方法,但是我无法理解为什么我不能用这种方法得到理想的结果,是否有人可以解决问题?