I've tried searching for solutions and couldn't find any accurate ones. I keep getting the same error when launching my UWP/XAML app:
CS1061 'MainPage' does not contain a definition for 'RootFrame_OnNavigated' and no accessible extension method 'RootFrame_OnNavigated' accepting a first argument of type 'MainPage' could be found
I've gone through the documentation and changed
rootFrame.Navigate(typeof(MainPage), e.Arguments);
to
rootFrame.Navigate(typeof(Page1), e.Arguments);
in order to specify Page1 in the call to Frame.Navigate instead of MainPage. (https://learn.microsoft.com/en-us/windows/apps/design/basics/navigate-between-two-pages)
Here is the code in MainPage.xaml:
<muxc:NavigationView x:Name="NavigationViewControl"
IsTitleBarAutoPaddingEnabled="False"
IsBackButtonVisible="Visible"
Header="Home"
DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
SelectionFollowsFocus="Enabled"
ItemInvoked="NavigationView_OnItemInvoked"
PaneDisplayMode="Auto"
Canvas.ZIndex="0">
<muxc:NavigationView.MenuItems>
<muxc:NavigationViewItem Icon="Home" Content="Home" x:Name="Menu1Item" Tag="Page1"/>
<muxc:NavigationViewItem Icon="Contact" Content="Account" x:Name="Menu2Item" Tag="Page2"/>
<muxc:NavigationViewItem Icon="Bullets" Content="Absences" x:Name="Menu3Item" Tag="Page3"/>
<muxc:NavigationViewItem Icon="Library" Content="Grades" x:Name="Menu4Item" Tag="Page4"/>
<muxc:NavigationViewItem Icon="Flag" Content="Grad Reqs" x:Name="Menu5Item" Tag="Page5"/>
</muxc:NavigationView.MenuItems>
<Grid Padding="20">
<Frame x:Name="rootFrame" Navigated="RootFrame_OnNavigated"/>
</Grid>
</muxc:NavigationView>
</Grid>
MainPage.xaml.cs:
private void NavigationView_OnItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
{
FrameNavigationOptions navOptions = new FrameNavigationOptions();
navOptions.TransitionInfoOverride = args.RecommendedNavigationTransitionInfo;
string navItemTag = args.InvokedItemContainer.Tag.ToString();
Type pageType = null;
if (navItemTag == "Page1")
{
pageType = typeof(Page1);
}
else if (navItemTag == "Page2")
{
pageType = typeof(Page2);
}
else if (navItemTag == "Page3")
{
pageType = typeof(Page3);
}
if (pageType == null)
{
return;
}
rootFrame.NavigateToType(pageType, null, navOptions);
}
I don't see any missing references or definitions, so I'm confused. I made sure spelling and casing was correct.