diff --git a/dev/NavigationView/NavigationViewItemPresenter.cpp b/dev/NavigationView/NavigationViewItemPresenter.cpp
index a7453a2f3a..3b8decf961 100644
--- a/dev/NavigationView/NavigationViewItemPresenter.cpp
+++ b/dev/NavigationView/NavigationViewItemPresenter.cpp
@@ -38,14 +38,16 @@ void NavigationViewItemPresenter::OnApplyTemplate()
m_expandCollapseChevron.set(expandCollapseChevron);
m_expandCollapseChevronTappedToken = expandCollapseChevron.Tapped({ navigationViewItem, &NavigationViewItem::OnExpandCollapseChevronTapped });
}
-
navigationViewItem->UpdateVisualStateNoTransition();
// We probably switched displaymode, so restore width now, otherwise the next time we will restore is when the CompactPaneLength changes
- if (navigationViewItem->GetNavigationView().PaneDisplayMode() != winrt::NavigationViewPaneDisplayMode::Top)
+ if(auto&& navigationView = navigationViewItem->GetNavigationView())
{
- UpdateCompactPaneLength(m_compactPaneLengthValue, true);
+ if (navigationView.PaneDisplayMode() != winrt::NavigationViewPaneDisplayMode::Top)
+ {
+ UpdateCompactPaneLength(m_compactPaneLengthValue, true);
+ }
}
}
diff --git a/dev/NavigationView/NavigationView_ApiTests/NavigationViewTests.cs b/dev/NavigationView/NavigationView_ApiTests/NavigationViewTests.cs
index e0a1463c80..893263b993 100644
--- a/dev/NavigationView/NavigationView_ApiTests/NavigationViewTests.cs
+++ b/dev/NavigationView/NavigationView_ApiTests/NavigationViewTests.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using MUXControlsTestApp.Utilities;
@@ -685,5 +685,26 @@ public void VerifySelectedItemIsNullWhenNoItemIsSelected()
Verify.AreEqual(null, navView.SelectedItem, "SelectedItem should have been [null] as no item is selected");
});
}
+
+ [TestMethod]
+ public void VerifyNavigationViewItemInFooterDoesNotCrash()
+ {
+ RunOnUIThread.Execute(() =>
+ {
+ var navView = new NavigationView();
+
+ Content = navView;
+
+ var navViewItem = new NavigationViewItem() { Content = "Footer item" };
+
+ navView.PaneFooter = navViewItem;
+
+ navView.Width = 1008; // forces the control into Expanded mode so that the menu renders
+ Content.UpdateLayout();
+
+ // If we don't get here, app has crashed. This verify is just making sure code got run
+ Verify.IsTrue(true);
+ });
+ }
}
}
\ No newline at end of file
diff --git a/dev/NavigationView/TestUI/NavigationViewCompactPaneLengthTestPage.xaml b/dev/NavigationView/TestUI/NavigationViewCompactPaneLengthTestPage.xaml
index 9cbadfe181..6760fba711 100644
--- a/dev/NavigationView/TestUI/NavigationViewCompactPaneLengthTestPage.xaml
+++ b/dev/NavigationView/TestUI/NavigationViewCompactPaneLengthTestPage.xaml
@@ -36,6 +36,9 @@
+
+
+