.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Silverlight >> Post New Resource Bookmark and Share   

 Subscribe to Articles

TreeView Node Selection and Navigate to page in Silverlight

Posted By:Diptimaya Patra       Posted Date: May 01, 2010    Points: 25    Category: Silverlight    URL: http://www.dotnetspark.com  

TreeView Node Selection and Navigate to page in Silverlight. In this article we will see how we can load different pages based on the selection we make in TreeView.
 

Creating Silverlight Project

Fire up Visual Studio 2008 and create a new Silverlight 3 Project. Name it as LOBSL3.

image1.gif

Let's have a design for our MainPage.xaml.

image2.gif

As you see in above image we have two panes, the left pane would have the Tree View. And the right side pane would contain the target page.

So, let's add one.

image3.gif

So we have several nodes.

Our aim of this article is to load different pages on different TreeView node selection.

So let's have some pages.

Now in TreeViewItem's Selected event we need to clear the value of the Content Border and again set it to our target Page.
Like following:

private void tviPartnersDetail_Selected(object sender, RoutedEventArgs e)
{
    BDContent.Child = null;
    PartnerDetail pd = new PartnerDetail();
    BDContent.Child = pd;
}

private void tviProductsDetail_Selected(object sender, RoutedEventArgs e)
{
    BDContent.Child = null;
    ProductDetail pd = new ProductDetail();
    BDContent.Child = pd;
}

As simple as that, so let's run the application.

image4.gif

image5.gif

image6.gif

image7.gif

This article was requested by one of my article reader, I know it is a simple thing to do, but I gave with some sample so that it would clear.

You can also download the sample project used in above example.

Hope it helps.

 Subscribe to Articles

     

Further Readings:

Responses
Author: raz         Company URL: http://www.dotnetspark.com
Posted Date: July 05, 2011

very cool indeed!

Would it be possible to use culture/localisation from main page startup (select a language) then when navigating to a page it picks up language chosen and changes content?
Author: raz         Company URL: http://www.dotnetspark.com
Posted Date: July 05, 2011

very cool indeed!

Would it be possible to use culture/localisation from main page startup (select a language) then when navigating to a page it picks up language chosen and changes content?

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend