NEW FEATURE: ContentControlNavigationAdapterBehavior and PanelNavigationAdapterBehavior

39 views
Skip to first unread message

Rishi Oberoi

unread,
Jan 13, 2011, 6:24:39 AM1/13/11
to nro...@googlegroups.com
Relatively speaking, in nRoute, it is quite easy to turn any control into a navigation container - just extend it by implementing the INavigationHandler interface. However, this is not always an option and is somewhat invasive; so one of other mechanism to achieve the same is to create an attachable NavigationAdapter, which essentially turns the control into a navigable control. These "attachable" adapters take the shape of behaviors, and we have three such built-in behaviors:
  • ItemsControlNavigationAdapter Behavior: This allows you to handle navigation in any ItemsControl derivative control, e.g. a ListBox
  • ContentControlNavigationAdapter Behavior: This allows you to handle navigation in any ContentControl derivative control, e.g. a ChildWindow
  • PanelNavigationAdapter Behavior: This allows you to handle navigation in any Panel derivative control, e.g. a Grid
The latter two above are new to nRoute, and since they target two of the most common container types in Silverlight/WPF they extend the usability of navigation quite a bit - and in a lightweight fashion too. For example consider a PivotItem in WP7, to turn each pivot into a pseudo navigation container just drag-drop the ContentControlNavigationAdapter Behavior onto each pivot item as such:
        <!--Pivot Control-->
        <controls:Pivot Title="MY APPLICATION">
            <controls:PivotItem Header="first">        
         <Custom:Interaction.Behaviors>
         <nBehaviors:ContentControlNavigationAdapterBehavior Url="Pages/InnerPage1"/>
         </Custom:Interaction.Behaviors>
            </controls:PivotItem>
            <controls:PivotItem Header="second">             
         <Custom:Interaction.Behaviors>
         <nBehaviors:ContentControlNavigationAdapterBehavior Url="Pages/InnerPage2"/>
         </Custom:Interaction.Behaviors>
            </controls:PivotItem>
        </controls:Pivot>

The benefit being you can now considerably simplify the composition of your applications by breaking them down into self-composing sub-containers, which are self-navigating too (i.e. you can navigate within the pivot itself). Further, you can earmark these adapters-enabled containers with handler names (use the NavigationHandler behavior), which then allows you to target them for navigation by handler-name from anywhere in the application.

Hopefully this feature should further simply composition of applications.
Rishi

Adrian Hara

unread,
Jan 13, 2011, 6:36:03 AM1/13/11
to nro...@googlegroups.com

Good stuff, for Pivot i was using a NavigationContainer inside the Pivot’s ItemTemplate, so it would be nice to “upgrade” J. Are these already part of some release or at least committed to codeplex? Or will be there in the future?

 

Freundliche Grüsse / Best regards

Adrian Hara
Cloud Developer
LinkedIn 


coresystems ag
Villa im Park | Dorfstrasse 69
5210 Windisch | Switzerland


Phone +41 56 500 22 22
Fax +41 56 444 20 50
Infoline +41 848 088 088
www.coresystems.ch
www.coresuite.com
follow us on
twitter

SAP Gold Partner (SSP)
Deutsche Telekom Audience Innovation Prize 2010
Best of Swiss Silverlight 2010 Gold Winner
Announced by Gartner as a Cool Vendor 2010

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and / or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

Rishi Oberoi

unread,
Jan 13, 2011, 7:39:58 AM1/13/11
to nro...@googlegroups.com
This is already part of the checked in code - see the nRoute5 folder. Also, if you going to use the v0.5 for WP7, one notable change is that the nRouteApplicationService in WP7 now derives from PhoneApplicationService, so you in your app.xaml you might need to set to setup something like this:

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <nRoute:nRouteApplicationService
            Launching="Application_Launching" Closing="Application_Closing" 
            Activated="Application_Activated" Deactivated="Application_Deactivated">
            <nRoute:nRouteApplicationService.SiteMapProvider>
                <!--Your SITEMAP will go here -->
            </nRoute:nRouteApplicationService.SiteMapProvider>
        </nRoute:nRouteApplicationService>
    </Application.ApplicationLifetimeObjects>

Cheers,
Rishi
Reply all
Reply to author
Forward
0 new messages