StatefulContainer(View) in StatefulContainer(View)

Jan 26, 2011 at 6:58 PM

 

What is the best way for use a StatefulContainer in a other StatefulContainer?
I have an StatefulContainer in the MainPage.xaml and in the CollectionView.xaml
When I click on a url in the CollectionView is the content of this view hosted in the MainPage StatefulContainer.
What can I do?

 <n:Application.ApplicationLifetimeObjects>
        <n:nRouteApplicationService>
            <n:XamlSiteMapProvider>
                <n:XamlSiteMapProvider.SiteMap>
                    <n:SiteMap>
                        <n:SiteMap.RootNode>
                            <n:NavigationNode>
                                <n:NodesCollection>
                                    <n:NavigationNode Title="Settings" Key="SettingsNode" Url="Content/Settings/"/>		
                                   <!-- MainView.xaml -->
                                    <n:NavigationNode Title="Home" Key="HomeNode" Url="Content/Home/"> 
                                        <n:NodesCollection>
                                            <!-- CollectionView.xaml -->
                                            <n:NavigationNode Title="Collection" Key="CollectionNode" Url="Content/Home/Collection/"> 
                                            </n:NavigationNode>
                                            <n:NavigationNode Title="Disc" Key="DiscNode" Url="Content/Home/Disc/">
                                            </n:NavigationNode>
                                            <n:NavigationNode Title="News" Key="NewsNode" Url="Content/Home/News/"/>
                                            </n:NavigationNode>
                                        </n:NodesCollection>
                                    </n:NavigationNode>
                                </n:NodesCollection>
                            </n:NavigationNode>
                        </n:SiteMap.RootNode>
                    </n:SiteMap>
                </n:XamlSiteMapProvider.SiteMap>
            </n:XamlSiteMapProvider>
        </n:nRouteApplicationService>
    </n:Application.ApplicationLifetimeObjects>

thx
Coordinator
Jan 26, 2011 at 8:30 PM
Edited Jan 26, 2011 at 8:32 PM

Well, I'm not sure I get your question - but let me reiterate what is a stateful container. Firstly, as you already know, a container is a control within which you can navigate, much like an iFrame in HTML. Secondly, some containers like the stateful container also provide an opt-in navigation state management function; to opt-in your View or ViewModel needs to implement the ISupportNavigationState contract (note the NavigationViewModelBase class already does that for you). 

Now, specifically what the Stateful Container provides for is that, as you navigate onto/off a page it can provide you back your save state everytime you hit the same url - for example if a user navigates to "Content/Home/Disc" for the first time and types in a "Disc" name, and then whist navigating away you can save the disc name in the state parameters collection. Then next time, if the user comes back to the "Content/Home/Disc" url again, the Stateful container will hand you back the state you gave it when fist navigating away - so basically as you navigate on the same url, you have the ability to restore the state. Now, the important thing to remember there is no concept of back or forward (i.e. directional) navigation here - everything is onwards only in a sense. If you want back-forward capability with the stateful kind of state behaviour then use the StatefulBrowsing Container.

Hope this helps,
Rishi 

PS, for more on containers see http://nroute.codeplex.com/wikipage?title=Navigation%20Containers

Feb 1, 2011 at 7:36 PM

here is a view of the app: http://cid-583c9afdfa5df548.office.live.com/self.aspx/Test/em.png

the MainWindow contains the fist "StatefulContainer" and the collection view contains a second "StatefulContainer".

when i clicked on any url (music, play or radio) is this view hosted in the MainWindow "StatefulContainer", but it should load in the collection view.

what is wrong?

 

thx

Coordinator
Feb 1, 2011 at 7:58 PM
Edited Feb 1, 2011 at 8:00 PM

Sorry help me again, when you click on any url like music, play, or radio which are in the "Second-Stateful" container you want to open them where? In the "Collection View" - what is the "Collection View"? Is it another navigation container or?

Rishi

PS: Your UI looks great :)

Feb 1, 2011 at 8:10 PM

ok, that is the ViewTree


Window

	+-- Settings

	+-- Home (contains Stateful)

		+-- Collection (contains Stateful)
			+-- Music

			+-- Play

			+-- Radio

		+-- disc (contains Stateful)

			+-- burn

			+-- rip

 

i hope this helps...

thx

Coordinator
Feb 1, 2011 at 8:52 PM

Oky, I still don't get the question properly - but let me take a shot. I believe you want to navigate in the second container when someone clicks Music/Play/Radio links. Well, one way to do it would be to earmark the "Second Stateful Container" with a container/handler name using the NavigationHandler behavior and then in your SiteMap you specify the name of the container you want it to navigate into - that is done by setting the "Handler"Name" property, like so:

                         <n:Application.ApplicationLifetimeObjects>
<n:nRouteApplicationService>
                                <n:XamlSiteMapProvider>
                                    <n:XamlSiteMapProvider.SiteMap>
                                        <n:SiteMap>
                                            <n:SiteMap.RootNode>
                                                <n:NavigationNode>
                                                    <n:NodesCollection>
                                                        <n:NavigationNode Title="Settings" Key="SettingsNode" Url="Content/Settings/"/>
                                                        <!-- MainView.xaml -->
                                                        <n:NavigationNode Title="Home" Key="HomeNode" Url="Content/Home/">
                                                            <n:NodesCollection>
                                                                <!-- CollectionView.xaml -->
                                                                <n:NavigationNode Title="Collection" Key="CollectionNode" Url="Content/Home/Collection/">
                                                                    <n:NodesCollection>
                                                                        <n:NavigationNode Title="Music" Url="Content/Home/Collection/Music/" HandlerName="SecondTierContainer" />
                                                                        <n:NavigationNode Title="Play" Url="Content/Home/Collection/Play/"  HandlerName="SecondTierContainer"/>
                                                                        <n:NavigationNode Title="Radio" Url="Content/Home/Collection/Radio/"  HandlerName="SecondTierContainer"/>
                                                                    </n:NodesCollection>
                                                                </n:NavigationNode>
                                                                <n:NavigationNode Title="Disc" Key="DiscNode" Url="Content/Home/Disc/">
                                                                </n:NavigationNode>
                                                                <n:NavigationNode Title="News" Key="NewsNode" Url="Content/Home/News/"/>
                                                        </n:NavigationNode>
                                                    </n:NodesCollection>
                                                </n:NavigationNode>
                                                </n:NodesCollection>
                                                </n:NavigationNode>
                                            </n:SiteMap.RootNode>
                                        </n:SiteMap>
                                    </n:XamlSiteMapProvider.SiteMap>
                                </n:XamlSiteMapProvider>
                            </n:nRouteApplicationService>
                        </n:Application.ApplicationLifetimeObjects>

The idea being you give a container a name (like "SecondTierContainer") and then in your nodes you tell it to navigate in the specified container.

Hope this answers your question.
Rishi 

Feb 2, 2011 at 5:29 AM

perfect, it works...

thx