none
button Navigate to Page RRS feed

  • Question

  • Hi,

    I am attempting to use a button to navigate to another page in my page.

    In the click method of my button, i have created a Hyperlink object as follows.

     

     

    Hyperlink hy = new Hyperlink();

     

    Uri uri = new Uri("scan.xaml");

    hy.NavigateUri = uri;

    I have played around with this and can not determine how to invoke this hyperlink? Is it possible?

    Thanks for any help,
    Ro
    Tuesday, August 18, 2009 4:20 PM

Answers

  • hi,

    thanks for the reply, i tried this for some reason it navigates to a blank page. The app does not crash but the the page does not load. The app has a navigation handler page and it appears to load to that!


    Hi ronan001,

    Make sure the format of the uri is correct. Take a look at the following example:

            private void Button_Click(object sender, RoutedEventArgs e)
            {
                this.NavigationService.Navigate(new Uri("pack://application:,,,/TestPage.xaml"));
            }


    Best regards,
    Bruce Zhou
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bruce.Zhou Monday, August 24, 2009 4:27 AM
    Friday, August 21, 2009 3:48 AM
  • You can use this.NavigationService.Navigate ("scan.xaml") instead of hyperlink



    Oscar Avarez Guerras - Arquitecto Software en I3B (I+D+I) Blog:http://geeks.ms/blogs/oalvarez Por favor marca como respuesta si te ha ayudado esta respuesta
    • Marked as answer by Bruce.Zhou Monday, August 24, 2009 4:27 AM
    Tuesday, August 18, 2009 4:51 PM
  • hi
    /Declaring a Frame for the Window to Load the Pages.
    Frame pageFrame = new Frame;

    put the below code on button event
    Uri pageuri = new Uri(test.xaml, UriKind.Relative);
    pageFrame.Navigate(pageuri);

    May be Solve ur Problem
    Harshad..... Always 4 U
    • Marked as answer by Bruce.Zhou Monday, August 24, 2009 4:27 AM
    Friday, August 21, 2009 12:03 PM

All replies

  • You can use this.NavigationService.Navigate ("scan.xaml") instead of hyperlink



    Oscar Avarez Guerras - Arquitecto Software en I3B (I+D+I) Blog:http://geeks.ms/blogs/oalvarez Por favor marca como respuesta si te ha ayudado esta respuesta
    • Marked as answer by Bruce.Zhou Monday, August 24, 2009 4:27 AM
    Tuesday, August 18, 2009 4:51 PM
  • hi,

    thanks for the reply, i tried this for some reason it navigates to a blank page. The app does not crash but the the page does not load. The app has a navigation handler page and it appears to load to that!

    • Proposed as answer by AnsariM Thursday, August 20, 2009 9:20 PM
    • Unproposed as answer by Bruce.Zhou Friday, August 21, 2009 3:46 AM
    Tuesday, August 18, 2009 4:59 PM
  • hi,

    thanks for the reply, i tried this for some reason it navigates to a blank page. The app does not crash but the the page does not load. The app has a navigation handler page and it appears to load to that!


    Hi ronan001,

    Make sure the format of the uri is correct. Take a look at the following example:

            private void Button_Click(object sender, RoutedEventArgs e)
            {
                this.NavigationService.Navigate(new Uri("pack://application:,,,/TestPage.xaml"));
            }


    Best regards,
    Bruce Zhou
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bruce.Zhou Monday, August 24, 2009 4:27 AM
    Friday, August 21, 2009 3:48 AM
  • Indeed. You must use pack uris http://msdn.microsoft.com/en-us/library/aa970069.aspx
    Oscar Avarez Guerras - Arquitecto Software en I3B (I+D+I) Blog:http://geeks.ms/blogs/oalvarez Por favor marca como respuesta si te ha ayudado esta respuesta
    Friday, August 21, 2009 7:06 AM
  • hi
    /Declaring a Frame for the Window to Load the Pages.
    Frame pageFrame = new Frame;

    put the below code on button event
    Uri pageuri = new Uri(test.xaml, UriKind.Relative);
    pageFrame.Navigate(pageuri);

    May be Solve ur Problem
    Harshad..... Always 4 U
    • Marked as answer by Bruce.Zhou Monday, August 24, 2009 4:27 AM
    Friday, August 21, 2009 12:03 PM
  • ah excellant, thanks a million Bruce, your solution has worked correctly for me.

    Thanks again.
    Sunday, August 30, 2009 8:02 PM