-2

I'm trying to go to another page when clicking a button. How could i do this.

I tried using a NavigationViewItem but it didn't work.

Marcelsky
  • 55
  • 1
  • 6

1 Answers1

1

The NavigationViewItem you posted is used in UWP.

If it is a WinUI3 project, then you need to refer to this document, use Navigate.

the relevant code samples are as follows.

xaml

<Button x:Name="myButton" Click="myButton_Click"/>

xaml.cs

private void myButton_Click(object sender, RoutedEventArgs e)
{

    Frame rootFrame = new Frame();          
    this.Content = rootFrame;

    rootFrame.Navigate(typeof(BlankPage1), null);
      
}
Junjie Zhu - MSFT
  • 2,086
  • 1
  • 2
  • 6