拆分Generic.Xaml - 问题加载合并集.请帮助Source

6 wpf themes generic.xaml

在一个非常大的控件库上工作,generic.xaml变得简单失控.我想通过控制来分割它(虽然一次只用于一个只包含一些简单的命名空间).

为此,我正在添加更多资源字典.

然后,在generic.Xaml中我添加:

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="Themes/Generic.Core.xaml" />
</ResourceDictionary.MergedDictionaries>
Run Code Online (Sandbox Code Playgroud)

并且...得到加载错误.

什么是正确的网址?

这是:

  • 在仅包含控件(不是exe或其他)的dll文件中.
  • generic.Xaml和另一个(现在:Generic.Core.xaml)存在于同一个程序集中,相同的文件夹.

我阅读了关于包URL的MSDN部分,但这听起来很复杂.

;) 请帮忙.

小智 13

找到了:

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/Tradex.Presentation;component/Themes/Generic.Core.xaml" />
</ResourceDictionary.MergedDictionaries>
Run Code Online (Sandbox Code Playgroud)

这样可行.
需要为程序集添加前缀(替换Tradex.Presentation为程序集名称)并从component项目开始.