主题\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="WPF Commons;component/Controls/Layout/Foo/FooItem.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
控件\布局\Foo\FooItem.xaml:
<Style TargetType="{x:Type l:FooItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type l:FooItem}">
<Border>
<ContentPresenter ContentSource="Header" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
如果我将整个样式复制到我的用户控件资源中,它可以正常工作。但是,如果我不这样做,用户控件就会显示为空。在 Expression Blend 4 中,我右键单击并选择了Edit Template
>,但它不允许我选择Edit a Copy...
,这使我相信某些事情严重错误并且 Generic.xaml 没有正确加载。我认为它是 Generic.xaml,因为如果我删除 MergedDictionary 调用并将 xaml 样式直接复制/粘贴到 Generic.xaml 中,它仍然不起作用。