If you create a customizable application you’ll most likely use Resource Dictionaries, you can choose to have the default application style inside the application assembly to preserve the look you envisioned for that application and as a fail-safe. Today we’ll see how to load a Resource Dictionary, both from the application assembly and from the file system.
Application.Current.Resources = (ResourceDictionary)Application.LoadComponent(
new Uri(string.Format(“themes\\{0}\\{0}.xaml”, theme), UriKind.Relative));
This sample code works both for the assembly stored Resource Dictionary as well as for the File System. The LoadComponent() Method returns an Object, that object is the root element of the loaded XAML, so, you could have any type of XAML element and load it anytime during the application execution. This trick is useful for a themes implementation, loading XAML vectors or even custom animations.