locked
How to navigate from one .xaml page to another? RRS feed

  • Question

  • Hello,

    I know there are probably many other people who have asked this question before many times.
    But, I couldn't find the answer, anywhere.
    It would be really helpful if someone could help me.

    How do you navigate to another .xaml page? Using C#, I know how to do it in Xaml, but how do you do it in C#. 

    Sunday, October 31, 2010 10:47 AM

Answers

  • Hi,

    It depends on what kind of template you are using.

    If you are using a "Silverlight Application" and your page is a "User Control"

    then you can navigate to the next page by creating a instance of the page and putting it to the "RootVisual"

    Like

    UserControl2 page2 = new UserControl2();

    App.Current.RootVisual = page2;

     

    But if you are using a "Silverlight Navigation Application"  and you have developed "Silverlight Page"s in your project.Then you can use the contentFrame.Navigate method.

     Like

    contentFrame.navigate(new Uri("/Page2",UriKind.Relative));

     

    ContentFrame resides in MainPage.xaml;

     

    Hope this helps.

    Sunday, October 31, 2010 11:02 AM