简体   繁体   中英

NavigationWindow dataflow

I am writing my first wpf application now .

I want to use a NavigationWindow on each page the user make selections and all the data should be available on the next pages, I have about 6 page.

How I should path all the data ? via the constructor ? or there is some smarter way in WPF .

On the last page there will be a lot data to path from the previous pages.

I would attack this from one of two ways: The Code-behind way (Easy, but difficult to expand, also will get very messy), and the MVVM way (Takes some learning, separates concerns, easy to extend, manage).

In the code-behind way, I would just have a Tab control with the tab headers styled the way you want them (you can style them to look like just about anything you want). In the code-behind you could have some logic that specifies that X Tab is not enabled or Visible until Y criteria are met.

There is a better way, but it comes with a bit of a learning curve, the MVVM design pattern. You would have 6 Page objects that are really just CLR objects that define the contents of the page (eg if it is a questionnaire your page objects would contain question objects and title objects for instance).

You could have a couple of Views, a navigation View, and a page view. The NavigationView would be bound to a NavigationViewModel which would have the logic necessary to change the page. The PageView would be bound to one of 6 PageViewModels and the PageViews DataContext (which provides that binding) could be changed based on the NavigationViews logic.

Night Walker,

It is difficult to make out exactly what you want to do from your explanation. First, the NavigationWindow is the frame of your application, I think you know this but I just wanted to make sure we understood that we're not creating new instances of the NavigationWindow. I think you mean 'Pages'. Pages are the content of a Navigation window and represent some target that you want to appear in the ContentPresenter that is provided by the NavigationWindow.

I'm again not sure how you are using the phrase 'Path the data'. Typically you would create Pages either directly in the project or in satellite projects and then reference them using Pack URIs. An example of how Pack URIs are constructed can be found here.

http://msdn.microsoft.com/en-us/library/aa970069(v=vs.85).aspx

You can then navigate to the pack URLs using an expression that looks like:

 this.Navigate(new Uri("pack://application:,,,/MyAssembly;component/MyPage.xaml", UriKind.Absolute);

If you don't want to get involved with all the nuts-and-bolts of the framework for navigation and just want to focus on the application for your users, you can check out the professional version of the NavigationControl that I put together:

http://www.teraque.com/products/explorer-chrome-suite/

There's an free demo you can download.  If this is was you are looking to do I can give you pointers if you don't want to purchase the package directly.

Sincerely,

Donald Roy Airey

donald.roy.airey@teraque.com

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