Sep 6, 2010 at 11:47 AM
Edited Sep 6, 2010 at 11:55 AM
Let me try answer your questions, point-by-point:
Q. How do I add the wizard pages to the container?
A. Well, you don't have to add them all at once, that's what you use navigation for. So like navigate from one page to another just use the NavigateAction behavior.
Q. Do containers support tabs?
A. Well, you must understand that a "navigation container" is something that can handle a navigation request/response (see the INavigationHandler interface). So tabs natively are not navigation containers, though minimally by either implementing INavigationHandler
by inheriting it or by creating a Navigation Adapter for it you can make it handle navigation (see http://www.orktane.com/Blog/post/2010/06/30/Creating-a-Netflix-App-using-nRoute-A-Step-by-Step-Guide.aspx for
an example on how to create adapters)
Q. About using Tabs?
A. Personally, I wouldn't use tabs for creating a Wizard control but you could. The problem with the tabs control is that tends to re-load pages when switched on/off a tab. You can create a similar effect/solution by just using the provided containers -
as all you'll be doing is to show one view at a time.
Q. Also how can I access the navigation container from within the view model?
A. You don't - in VMs you keep away the View related stuff. Also if you know how containers work (just like web browsers), when you navigate (like when you click a hyperlink) within a container it just picks up the container itself by walking up the
visual tree, unless you specify another container.
Q. Is there some way of accessing container by name?
A. Yes, see the "Globally Named Navigation Containers" section http://www.orktane.com/Blog/post/2010/04/13/nRoute-Now-More-Wholesome.aspx
Q. Also you mention that if a view is added to the container and the view doesn't have a view model sepcified then it will be given the parent view model, will this happen automatically?
A. Yes. And that's the setup I talked about in option 1. So you parent view will look something like:
<n:NavigationContainer Url='Pages/MyWizard/Page1' />
As you can see above we've initialized the container to start with the url "Pages/MyWizard/Page1" - that Url maps to a UserControl (say Page1.xaml) which has been earmarked with the MapNavigationContent attribute:
public partial class Page1 : UserControl
Now, importantly, this page doesn't have it's own VM - so it would inherit the parent's VM. So Page1.xaml could navigate to Page2.xaml which would be the second screen in your Wizard, and Page2 would be mapped with the Url like "Pages/MyWizard/Page2".
So basically all you need to do is navigate from one Url to another, and you should get your wizard going.
Hope you got the basic idea?