mic*_*ael 16 wpf custom-controls resourcedictionary generic.xaml
主题\ 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>
Run Code Online (Sandbox Code Playgroud)
控制\布局\富\ 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>
Run Code Online (Sandbox Code Playgroud)
如果我将整个样式复制到我的usercontrol资源中,它可以正常工作.但是,如果我不这样做,则usercontrol显示为空.在Expression Blend 4中,我右键单击并选择Edit Template>,但它不会让我选择Edit a Copy...哪个让我相信某些内容严重错误并且Generic.xaml未正确加载.我认为它是Generic.xaml,因为如果我删除MergedDictionary调用并将xaml样式直接复制/粘贴到Generic.xaml中,它仍然无效.
m-y*_*m-y 31
我会猜测你改变了你的AssemblyInfo.cs文件并更改(或删除)了以下行:
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
Run Code Online (Sandbox Code Playgroud)
你需要告诉大会你的ThemeInfo.:)