Recently I have been anatomizing Kevin’s Bag-O-Tricks. I was quite freaked out when I was trying to figure out how those custom controls are able to find their “Skins”. It turns out that Themes/generic.xaml plays the non-trivial role. Well, I don’t think I should go on with my shameful experience to discover this. Let me just focus on its function.
Here I quote the words from The FlexWinds Blog:
” The standard controls that are available out of the box are useful for most scenarios. However you do want the ability to create your own custom controls. WPF provides you that ability and also gives you a chance to define a default style for your control. Since your custom control will be in a separate .Net assembly, the default style is specified in a generic.xaml file that sits in the /themes folder. When WPF loads your control, it probes into the /themes/generic.xaml file and looks for a style definition for that control (TargetType = your control’s type). ”
Another thing needed to bear in mind is:
AssemblyInfo.cs needs a ThemeInfo attribute, with the value of
[assembly: ThemeInfo(ResourceDictionaryLocation.SourceAssembly, ResourceDictionaryLocation.SourceAssembly)]
Here is a good tutorial teaching you how to create and apply custom themes.