Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear all,

I'm working on WPF application, for which I'd like to create option which allows non-programmers to change the application's appearance (aka skin). As I could see in WPF documentation, appearance of windows and UI controls is defined in XAML language, and can be edited using Microsoft Expression Blend program which is suited for designers and other non-programmers. So my question is: "How do I make my WPF based application to read some XAML code and create some window(s) and/or UI controls described by it in runtime?"

I chose WPF and XAML based solution because XAML defined appearance is, to the best of my knowledge, the most editable and I already have tool for editing it (Blend), but if you have better idea, please do not hesitate to share it with me.

You don't need to give me the exact code solution. A pointer to appropriate documentation will suffice.

Thanks in advance.
Posted

You can load in an external xaml file as a ResourceDictionary that contains your styles. Then when you create windows, buttons, etc, you can use those styles from the default set that you include in the app. When someone wants to change to a new skin and has their own file, then you can clear your ResourceDictionary and then load a new one and merge it into the dictionary that is built into the app class.

Let me know if you need code examples, because I do this in a few apps.
 
Share this answer
 
Comments
jobyjames 2-Aug-11 4:57am    
yes i need code example
Thanks Steve.

So far I like your solution. If it's not much trouble an example or two would be very much appreciated.

Thanks again.
 
Share this answer
 
Comments
Steve Maier 3-Feb-11 15:20pm    
Next time comment in the answer and I will get notified that someone commented. I just happened to look back at this. Normally I would not have.
Steve Maier 3-Feb-11 15:27pm    
I will put together a stand alone example tonight for you so that I do not give you "proprietary code".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900