RadNavigation deep linking

by XAML Team | Comments 3

Deep linking is an unique feature of RadNavigation allowing you to use page navigation by simply changing the URL in the browser address bar. Now you can provide a link directly to every page from your application. Implementing this RadNavigation feature is just as easy as using the other navigation classes all you have to do is just follow the next steps:

 

1. Create Silverlight application.
In order to use deep linking in page navigation scenario you have to make sure that any changes in the state the page is reflected to the browser’s address (bookmark). To do this you have two choices:
 
-    If you do not want to use AjaxBrowserHistory (Back/Forward buttons of the browser) functionality set:
       
 NavigationService.UseBrowserHistory = true;  

-    Otherwise if you use browser history set :        
NavigationService. UseHistoryBookmark = true

 

 

For more information visit the help section.

 

In both cases you must set these properties to true before writing any other code in App.xaml.cs:

private void Application_Startup(object sender, StartupEventArgs e) 
        { 
             NavigationService.UseBrowserHistory = true
            // NavigationService.UseHistoryBookmark= true; 
            …. 
        } 

 2. The next step is to add some RadPage classes in your application.

3. After you have added all the pages and navigation structure between them then you are ready to use DeelLinking just go again in App.xaml.ca and add the following:

 

private void Application_Startup(object sender, StartupEventArgs e) 
        { 
            ….. 
            if (!NavigationService.LoadDeepLink()) 
            { 
                //Navigate to some page  
            } 
        } 

NavigationService.LoadDeepLink() method checks wheter you have deep linking or just want to navigate to some page.
So the final peas of code should look like the following:

 

private void Application_Startup(object sender, StartupEventArgs e) 
        { 
            NavigationService.UseBrowserHistory = true
            this.RootVisual = new RadFrameContainer(); 
            NavigationService service = NavigationService.GetNavigationService(); 
            if (!NavigationService.LoadDeepLink()) 
            { 
                service.Navigate(new Page1()); 
            } 
        } 

 

 RadNavigation framework uses the NavigationIdentifier  property of RadPage in order to change borwser bookmarks while navigating between pages. By default its value is set to the full name of the RadPage class. But if you prefer to use  can custom navigation identifiers or custom browser bookmarks.  You can also navigate to the same page but  with different content and different browser identifier.
The Silverlight application below shows how you can use all these features of the RadNavigation framework(The full source code you can find attached at the end of the blog post):


 

 BooksExample-source


3 Comments

Ben Hayat
Boryana, I have two questions for you:
a) You have the "EnableHistory=True" in he ASP tag. But if I'm using a plain HTML default page (and not an ASP page), can you tell me how I should set the EnableHistory=True?
b) Does the LoadDeepLinking method get the query string and parses it and automatically loads that page?
Thanks!
Valentin

Hi Ben, a) - EnableHistory with an ASP.NET/AJAX framework gives you the ability to use the browser buttons to go back/forward in your application. If you don't need the browser back/fwd buttons you don't need the ASP.NET/Ajax framework. In case you are using plain HTML page - you need to declare (entirely in XAML) two buttons for backward/forward. The framework support this scenario out of the box. See the new page navigation framework examples. In case you missed them - here they are:   1. How to create a wizard with Silverlight - http://demos.telerik.com/silverlight/wizardexample/,   2. Advanced scenario - custom history and dynamic pages with page navigation for silverlight - http://demos.telerik.com/silverlight/booksexample/,  3. Cars explorer -  http://demos.telerik.com/silverlight/carsexample/ You can also check the new help topics for the page navigation. We create almost 50 articles about how to use the page navigation framework: http://www.telerik.com/help/silverlight/radpagenavigation-overview.html

b) - Yes. This method tris to load a page from the url automatically. If a user has stored a bookmark to a specific page of your application and later tries to load that page again, the framework automatically will handle the job for you and will load the correct page.

..Ben
>>If you don't need the browser back/fwd buttons you don't need the ASP.NET/Ajax framework. In case you are using plain HTML page - you need to declare (entirely in XAML) two buttons for backward/forward. The framework support this scenario out of the box.<<
Thanks Valentin;
Yes, I would like to use the browser back/fwd buttons and currently I'm using Default.html. So, just to confirm what you said, I should switch to Default aspx and then set "EnableHistory=True". Then I can continue with the rest!

Comments

  1.    
      
      
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)
Read more articles by XAML Team - or - read latest articles in Developer Tools
Product Families