tags:

views:

29

answers:

2

I need to create a WPF application which is maximized and which rotates amongst about 10 different screens. Each screen will take the entire area and show different content.

I already know how to maximize the window with

My question is what is best to put inside that window to achieve what I want?

Ideally I'd be able to have 10 different .xaml files and I just load one after the other to take the entire screen. I'm not sure the best approach for accomplishing this in WPF.

Thank you!

A: 

This sounds like a classic MVVM application, which is simply too much to put into detail here. Google MVVM or Model-View-ViewModel, or pick up the book Advanced MVVM by Josh Smith (widely regarded as an expert in such things).

However, this is basically what you are going to have:

  • One class, the ViewModel, is an abstraction of the data that you need to bind to
  • Your data Model
  • A View for each thing you want to show. A View is simply something that holds your UI, be it a DataTemplate or a UserControl. Each View is bound to the ViewModel

The Views are the things that will "rotate" (although rotate in WPF implies animation and/or transformation). How you switch between them is up to you, although it sounds almost like something that would be done with a DispatcherTimer and animation (i.e. like fading between pictures in a slideshow).

This question is really too broad for this forum - you will need to do quite a bit of research on WPF fundamentals before proceeding. Again, MVVM is a good direction to start.

EDIT: Something More Lowbrow, per OP Request
This is probably as simple was you can make it (and still create separate XAML files for each piece of content):

First, create 10 UserControls (XAML files) for the stuff you want to show.

Next, add an instance of each of these user controls to your main window. Set the Visibility of each of these to Collapsed, except the first one to show.

Put a "Next" button on the main window.

In the code-behind, handle the Click event for the Next button. In there, keep track of which UserControl is visible, by name. Set the one that is currently visible to Visibility.Collapsed, and set the next one that is supposed to be visible to Visibility.Visible.

This is certainly an ugly solution, and not very WPF-ish, but it will get the job done.

Wonko the Sane
Thank you for your thoughts - I was hoping for a bit more lowbrow answer.
Slaggg
Like for example - "just create your 10 zaml files, then switch between them with Application.Source = new Uri()" or something like that. This is a quick 1-hour application and I'd prefer a super simple approach - I just don't know WPF that well yet. Thanks!
Slaggg
Believe it or not, the answer is essentially that.
Wonko the Sane
I will update the answer with something "more lowbrow" but I still cannot give all the implementation details.
Wonko the Sane
Thank you for your help. John Bowen's answer provided a very quick and easy solution ... sorry to be "lowbrow" here but in this case was looking for simplest approach. thanks again!
Slaggg
+2  A: 

One quick way to do this is to use WPF's built in page navigation. By making your root window a NavigationWindow and each view a class derived from Page (similar to work with to a UserControl or Window) you can just set the NavigationWindow.Source to a relative URI that points to the page you want to show (like a web browser) and simply switch it as needed.

John Bowen
This worked great!
Slaggg
I added this tip to get rid of the navigation bar at the top of the NavigationWindow: http://stackoverflow.com/questions/3059650/how-to-hide-the-navigation-bar-in-the-page-wpf
Slaggg