WPF - How do I programmatically add a resource dictionary

JElster
JElster used Ask the Experts™
on
Hi..
How can I programmatically add the following resource dictionary to my C# code?

   <ResourceDictionary Source="/PresentationFramework.Aero;component/themes/aero.normalcolor.xaml"/>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
ResourceDictionary resourceDictionary = new ResourceDictionary();
                resourceDictionary .Source = new Uri
("/PresentationFramework.Aero;component/themes/aero.normalcolor.xaml", UriKind.Relative);

Now if you want to merge it with your application resources then you do the following:

 Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);
Commented:
As code:
ResourceDictionary resourceDictionary = new ResourceDictionary();
                resourceDictionary .Source = new Uri("/PresentationFramework.Aero;component/themes/aero.normalcolor.xaml", UriKind.Relative);

Now if you want to merge it with your application resources then you do the following:

 Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);    

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial