WPF自定义控件库和普通类库之间的区别?

Dav*_*man 5 wpf prism

几个月前我发布了一个关于跨程序集共享资源字典的问题.事实证明,您可以使用Component Resource Key标记扩展来实现.当时,我只能使用WPF自定义控件项目,而不是普通的类库项目.

现在我需要使用现有的普通类库项目来托管共享资源字典.这意味着我需要改进类库项目以支持组件资源键标记扩展.我已将Themes文件夹和Generic.xaml资源字典文档添加到类库项目,以及对PresentationCore,PresentationFramework和WindowsBase的引用.不幸的是,这似乎没有成功.

所以,这是我的问题:除了上述内容之外,WPF自定义控件库项目具有普通类库项目的功能吗?或者,换句话说,我还可以添加到我的类库项目中以使此功能正常工作吗?谢谢.

Cam*_*and 6

除了额外的WPF引用之外,WPF自定义控件库模板在AssemblyInfo中还有一个额外的属性.

[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)

ThemeInfoAttribute指定为程序集中的类型存储主题词典的位置.