Question

What is the basic difference between the WPF custom control library and wpf class library.I want to understand the difference in terms of dll and architecture point of view .Because custom control is itself a class and WPF class library is also contains class.But custom control class is not working in wpf class library.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top