Assembly-wide / root-level styles in WPF class library

后端 未结 7 2005
夕颜
夕颜 2021-01-30 06:28

I have a C# (2008/.NET 3.5) class library assembly that supports WPF (based on this article).
I\'ve created several windows, and am now attempting to create a common style

7条回答
  •  爱一瞬间的悲伤
    2021-01-30 07:26

    This sounds like a job for theming.

    1. Add a /themes/generic.xaml ResourceDictionary to your project.
    2. Add the following to AssemblyInfo.cs: [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
    3. ?
    4. Profit!

    Any resources you add to generic will be used by all controls. Also you can make profile specific themes (Luna, Aero etc.) by including a ResourceDictionary file with the correct theme name in the themes directory.

    Heres a link to more info: Create and apply custom themes

提交回复
热议问题