7

I am developed the Windows mobile application I've added the button for VS blend 2015 , but there's no button navigate to option how to bind to my button for the page sub.xaml

<Button x:Name="button" Content="Enter" Height="42" Margin="122,-113,0,0" 
     VerticalAlignment="Top" Width="144" Foreground="#FF50CBC5" 
     Background="#FF0F0E0E" HorizontalAlignment="Left"/>
Codeone
  • 1,173
  • 2
  • 15
  • 40

3 Answers3

10

The hyperlink button gives you the option to navigate to another page onclick.

This screen shot is from Blend.

enter image description here

So change your mark up as follows, including the generated Click handler.

<HyperlinkButton x:Name="button" Click="HyperlinkButton_Click"
    Content="Enter" Height="42" Margin="122,-113,0,0" 
    VerticalAlignment="Top" Width="144" Foreground="#FF50CBC5" 
    Background="#FF0F0E0E" HorizontalAlignment="Left"/>

Then in your cs, you need to direct the navigation.

// Button to navigate to sub.xaml page.
private void HyperlinkButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
    // Navigate back to sub.xaml page.
    this.Frame.Navigate(typeof(SubPage));
}
1

You will have a Click event for button. In that click event, write the code as

private void Button_Click(object sender, RoutedEventArgs e)
    {    
        NavigationService.Navigate(new Uri("/sub.xaml", UriKind.RelativeOrAbsolute));   
    }  
Sailesh Babu Doppalapudi
  • 1,534
  • 1
  • 10
  • 22
1

You can do this using following steps.

1st Step - add a new button on your window and change the properties as you wish.

2nd Step - double click on that button. then you will go to the cs file like this.

private void Button_Click(object sender, RoutedEventArgs e)
{    

}  

3rd Step - create new object of window that you want to navigate and open that, then close current window

private void Button_Click(object sender, RoutedEventArgs e)
{ 
    NewWindow newWindow = new NewWindow();
    newWindow.Show();
    this.Close();
}

Thanks.

Thili77
  • 1,061
  • 12
  • 20