view raw
djcouchycouch djcouchycouch - 6 months ago 40
C# Question

Loading XAML at runtime?

First some background: I'm working on an application and I'm trying to follow MVVM conventions writing it. One thing I'd like to do is to be able to give the application different "skins" to my application. The same application, but show one "skin" for one client and a different "skin" for another.

And so my questions are:

1. Is it possible to load a xaml file at run time and "assign" it to my app?

2. Can the xaml file be an external file residing in a different folder?

3. Can the application switch to another xaml file easily, or only at startup time?

So where should I start looking at for information on this? Which WPF methods, if they exist, handle this functionality?


Edit: the type of "skinning" I'm wanting to do is more than just changing the look of my controls. The idea is having a completely different UI. Different buttons, different layouts. Kinda like how one version of the app would be fully featured for experts and another version would be simplified for beginners.


I think this is fairly simple with the XamlReader, give this a shot, didn't try it myself, but I think it should work.