views:

1143

answers:

2

Is using WPF navigation in standalone applications is best practice? And can it be used with WPF MVVM pattern?

+5  A: 

To answer your second question, yes, WPF navigation can be used quite successfully with the MVVM pattern.

As far as the first question goes, the best answer is 'it depends'. Specifically, it depends on the application you are trying to create; some applications are logically 'navigation' applications, where the users are expected to navigate through a series of screens in some fashion, while other applications have different paradigms. The best advice I can give you is not to fight it - if your application makes sense in a navigation context, then by all means use WPF navigation, but if it doesn't then do not try to shoehorn it into one.

Perhaps the best way to determine whether or not your application uses a navigation paradigm is whether or not a back button makes sense; if it does, then you'll want to use Frame or NavigationWindow so that you can use the built-in WPF navigation support.

Nicholas Armstrong
Do you happen to know of any good examples of navigation being used in standalone WPF applications?
dthrasher
+1 for the "do not fight for it" thing. Many apps simply make zero sense in that navigation scenario.
TomTom
A: 

I don't think that System.Windows.Navigation is ready for production applications yet. I've found that using it in a WPF4 application is a frustrating experience if you need to pass data between pages.

I also encountered a serious bug that causes databinding to fail after using back or forward navigation.

Numerous WPF toolkits and frameworks exist for MVVM, MVC and MVP style applications. Virtually all of them replace the Hyperlink, Page, Frame and Journal classes that Microsoft provides with custom-built navigation services. So the developer community appears to have given System.Windows.Navigation a "vote of no confidence". Hopefully support for navigation-style apps will improve in the future.

If you have an application that's suited to the navigation metaphor, it's probably worth investigating these alternative frameworks. (Of course, these toolkits have their own learning curve associated with them.)

I'm still searching for a good approach to this problem myself.

dthrasher