【发布时间】:2014-06-05 19:28:02
【问题描述】:
我创建了资源字典并可以访问其中的样式,但我如何(如果可能)从中引用整个控件?
这是资源字典:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="MainWindowStyle" TargetType="Window">
<Setter Property="Background" Value="Transparent"></Setter>
<!--Can access this-->
</Style>
<Window x:Key="CustomWindow" Background="Transparent">
<!--Want to access this-->
</Window>
</ResourceDictionary>
这是主窗口 xaml 文件:
<Window x:Class="MyNamespace.MyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="640" Width="960" >
<!--setting Style={StaticResource MainWindowStyle} adds the style but I want this window to be replaced by the one in the resourcedictionary-->
<Grid>
</Grid>
</Window>
所以我基本上想用资源字典中创建的窗口替换xaml文件中的窗口。
【问题讨论】: