I am trying to do a simple page navigation but I am unable to find any documentation on how to do so in WinUI 3.0.
Currently, when I create a Blank App using WinUI 3.0, I get the following code created in App.xaml.cs
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
m_window.Activate();
}
private Window m_window;
While in many other examples I've found on the web, a root frame is defined in the OnLaunched event above.
How am I to define MainWindow.xaml or App.xaml such that I can get a frame where I can freely switch between Page1.xaml and Page2.xaml?
Edit: I've now found out that I can retrieve the frame by calling:
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
Frame rootFrame = m_window.Content as Frame;
m_window.Activate();
rootFrame.Navigate(typeof(UI.MainMenu));
}
But Navigate fails with a System.NullReferenceException: 'Object reference not set to an instance of an object.'
error. What am I doing wrong :S?