简体   繁体   中英

Create Single Window Navigation in WPF

I want to create a kiosk mode application using WPF. I want to use a single window because the user should not be able to exit this fullscreen application.

The application should guide the user trough a process. When the user proceeds trough the process, the screen should constantly change and show him the next step.

Usually I just create a single window and use a "state machine" to switch UserControls containing the information for the current step. Is there a better way to achieve this functionality? Maybe I would get a better result using multiple windows or Pages (never used them).

The reason why I am asking is that in future I want to have a simple, clean way of switching the content inside a single window. ie I am planning to implement some sort of animation when switching content (like sliding to the next / previous step). I don't want to put more effort into my current approach if it isn't the most flexible and clean one.

Any ideas?

PS: This is about desktop applications. Today I come from the Winforms environment and am experimenting with WPF.

There's a few ways you can achieve this.

First would be to use a Page based application, this will allow you to use a single window. Here is a pretty interesting tutorial

A bonus of using this approach is that navigation between pages is built in.

Your requirements are that you need to use animation for transitioning between pages, as far as I'm aware, using a Page based application cannot achieve this (I may be wrong). So your other option would be to use a UserControl MVVM approach.

This probably won't make a lot of sense now, but here goes:

You can use a single master view model which will hold multiple child view models, each of these could have a visibility property which dictates the visibility of the associated view. The master view model would simply be responsible for displaying the appropriate view model depending on where the user currently is in the application.

Using some clever XAML, you can create storyboards (animations) when the view becomes visible, which will allow you to achieve the crazy awesome animations that you require.

Anyway, that probably didn't make any sense, so here's a tutorial to get you started with MVVM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM