我正在开发一个WPF自定义控件库,在Themes文件夹中公开样式,如 Generic , Aero2 等。我还将我的程序集ThemeInfo设置为引用我的SourceAssembly。
[assembly: ThemeInfo(
ResourceDictionaryLocation.SourceAssembly,
ResourceDictionaryLocation.SourceAssembly
)]
但是这些样式仅在我合并App.xaml中的ResourceDictionary时应用:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MyWPFCustomControl;component/Themes/Generic.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MyWPFCustomControl;component/Themes/Aero2.NormalColor.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
问题:如何在不明确合并资源字典的情况下隐式加载基于主题的样式,如上所述?