I’m not sure how many of you at PDC have already installed “The Goods” CD that you received. When you do, and you start porting your WPF apps to this build, you’ll notice that the NavigationApplication class no longer exists. Don’t panic! All of the navigation features that you know and love are still around, and their usage model hasn’t changed much either. Before I go into too much detail on the change, here’s some background on the problems we had with the old Application/NavigationApplication split:
- The decision of Application vs. NavigationApplication has little to do with whether or not the app uses navigation â€“ Applications may use NavigationWindows, and NavigationApplications may use regular Windows. So why make the choice? Since the decision of whether or not to use navigation really happens at the Window level, not the app level, we’d rather let developers make the decision per window.
- There was no way to create a markup-only application using the vanilla Application class.
- When using NavigationApplication and setting the StartupUri, there was no way to set properties on the MainWindow before it was shown.
- People were confused about when to use an Application vs. a NavigationApplication. This is in large part because there were only 3 main differences between the two: Startup behavior, the Properties collection, and Navigation events.
Given these known drawbacks, we set out to provide one Application class that solves the problems above and still meets all of your app-management needs. The main changes are as follows:
- Moved StartupUri to Application – providing this property on the Application object maintains the existing startup behavior for NavigationApplications, and helps us enable the markup-only non-navigation Hello World scenario.
- Changed how StartupUri works â€“ if the XAML specified has a Window at the root, weâ€™ll create the Window (no navigation occurs); if the file has a Page at the root, weâ€™ll create the NavigationWindow implicitly and navigate to the Page.
- Window –> create the Window (donâ€™t navigate)
- NavigationWindow –> create the NavigationWindow (donâ€™t navigate)
- Page –> create NavigationWindow and navigate
- Moved Navigation events and Properties collection to Application
In general, most people have found the change relatively easy to adapt to, and they are appreciative of this simplification of the API. The most common migration path will simply be replacing your
<NavigationApplication> tags with
<Application> tags — and then everything should just work as it did before. If it turns out to be more difficult for you, or you have any questions about how to migrate, please let me know.