tags:

views:

399

answers:

3

WPF Noob question:

Can WPF applications can have their appearance change at runtime? I understand, through styles, that one can change the appearance of controls and UI elements, but I was envisoning something more along the lines of having two applications: one "editor" application and a "game" application, both running essentially the same code but having a totally different UI layout (the latter having fewer buttons, simpler controls, menu items, etc). The layout of the "game" UI could be designed by an artist, generally someone who doesn't have access to the underlying code.

How do I go about doing something like that? I'd just need a starting point.

Thanks!

+1  A: 

You have pretty much unlimited flexibility to manage the appearance of your WPF application at runtime so what you're suggesting is quite feasible.

Without knowing the full details of you app it does sound like you could create two different sets of UI controls one for editors and one for gamers and have both use the same underlying biz logic classes.

To select which mode to run your app in at runtime would be a matter of deciding which type of user you add and placing the editor or gamer user interface control onto the main layout container appropriately.

private void Window_Loaded(object sender, RoutedEventArgs e)
{
     if(user == editor) {
         this.LayoutRoot.Children.Add(editorUserControl);
     }
     else {
         this.LayoutRoot.Children.Add(gamerUserControl);
     }
}

And there are a myriad of other different ways you could do it as well.

sipwiz
A: 

Look at PhotoSuru for an example of an application that dynamically change it's layout (according to the window size)

kobusb
A: 

Without knowing exactly what you are aiming for I would suggest using MVVM. What you described is classic MVVM. You have one model but you have many views, in your case 2, for the same model.

So if you use some kind of MVVM framework, you can utilize dependency injection to display different views depending on what context you are running in.

I am a big Prism fan but there are many MVVM frameworks available. You might even get away with using 1 model, 1 view model and 2 views.

Marthinus