NavigationView leads to internal crash when close the application
Describe the bug
I have an app with TabView control. Inside selected tab I have NavigationView with different configuration of other controls. When I close app by X button, my app crash with such Exception
Exception thrown at 0x00007FFFEE0940AC in MyCRM.App.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x000000A68937D640.
Steps to reproduce the bug
-
Create App with TabView control
-
Inside TabViewItem put view like Master-Details where on the Master you have NavigationView
-
Assign elements to NavigationView.MenuItemsSource and template selector to NavigationView.MenuItemTemplateSelector

-
Expand some Menu items
-
Close the app by X button (right-top corner) Exception happens

Expected behavior
The app will be close without exception
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.2.4: 1.2.230217.4
Windows version
Windows 11 (21H2): Build 22000
Additional context
No response
Can you share a minimal reproducible example shown in following link? How to create a Minimal, Reproducible Example
I can confirm this crash still happens in the latest Win App SDK 1.4.231115000.
It seems to be most easily reproducible by not selecting either of the tabs. Just launch the application and click the window close button. It may not happen on every launch.
A minimal example is as simple as replacing the standard sample XAML content as follows:
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
<NavigationView PaneDisplayMode="Top" SelectionFollowsFocus="Enabled" IsBackButtonVisible="Collapsed" IsSettingsVisible="False">
<NavigationView.MenuItems>
<NavigationViewItem Content="Tab 1" Tag="Tab1Page" />
<NavigationViewItem Content="Tab 2" Tag="Tab2Page" />
</NavigationView.MenuItems>
<Frame x:Name="contentFrame"/>
</NavigationView>
</StackPanel>
@SeRgI1982 Would you be able to provide a min repro of this issue?
@StevoSM I tried your repro several times but am not seeing this exception. Are you seeing the same call stack with your repro?
@ojhad It appears that the crash only happened when there was no content in the NavigationView. Once I added content, I didn't see the crash anymore.