WPF中如何将style移出Generic.xaml

来源:百度知道 编辑:UC知道 时间:2024/06/03 16:39:35
我定义了1个customcontrol,VS中自动生成了个Themes\Generic.xaml,并把Style写在其中,我想把这个Style单独写成1个xaml文件,然后在Generic.xaml中包含文件的路径,该如何做呢?

可以把每个控件单独放在一个文件里面,这样方便管理.
资源文件中有一个MergedDictionaries属性,用于引用外部资源文件.具体用法如下.

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WPF.Controls;component/Themes/Shared.xaml" />
</ResourceDictionary.MergedDictionaries>