You can think of WPF Custom Control Library as a simple Class Library with a few more configurations:
ThemeInfo
assembly attribute:
[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)
)]
The above attribute specifies where to seek the default Styles/Templates for the control. You can get from the comments above what the ResourceDictionaryLocation.SourceAssembly
does, the default location in SourceAssembly
where the Resources
are searched is the special path Themes/Generic.xaml
which are created by default when you add a new WPF Custom Control Library.
You can add these manually and transform a Class Library into a WPF Custom Control Library.
Without the ThemeInfo
attribute the default Styles/Templates are searched only in application resource dictionaries and if you don't have one you will get an error. Thats why CustomControls
most commonly does not work with Class Library.