How to import one ResourceDictionary into other, in WPF?

前端 未结 3 1575
醉梦人生
醉梦人生 2021-02-07 00:54

Is it possible to add one resource dictionary into other one?

3条回答
  •  旧时难觅i
    2021-02-07 01:36

    Something like:

    ResourceDictionary resources = new ResourceDictionary();
    resources.Source = new Uri("/MyModule;component/MyModule.xaml", 
         UriKind.RelativeOrAbsolute);
    Application.Current.Resources.MergedDictionaries.Add(resources);
    

    Might be what you're looking for. We use code like this in our Prism Modules.

提交回复
热议问题