Step 1. Right click on your MauiApp Project, Add-> New Item.
Step 2. Select Maui Content Page (XAML), and rename the page to whatever you want in this example I will call it SecondPage.
Step 3. Navigate back to your MainPage.xaml file, and add the following:
<Button Text="Click to Navigate"
VerticalOptions="Center"
HorizontalOptions="Center"
Clicked="OnBtnClicked" />
Step 4. Navigate into MainPage.xaml.cs and add the following:
private void OnBtnClicked(object sender, EventArgs e)
{
App.Current.MainPage = new NavigationPage(new SecondPage());
}
Step 5. Compile and launch.
Conclusion: You are essentially creating a function "OnBtnClicked" within the MainPage.xaml.cs file and referencing that function into the Button component.