diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListDetailsView/ListDetailsView.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListDetailsView/ListDetailsView.bind index af80e92f2..b0a200550 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListDetailsView/ListDetailsView.bind +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListDetailsView/ListDetailsView.bind @@ -74,19 +74,20 @@ + - - - - - - - - + + + + + + + + diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Layout/ListDetailsView/ListDetailsView.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Layout/ListDetailsView/ListDetailsView.cs index 710d5dc5e..896a2c75a 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Layout/ListDetailsView/ListDetailsView.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Layout/ListDetailsView/ListDetailsView.cs @@ -10,6 +10,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using NavigationView = Microsoft.UI.Xaml.Controls; namespace Microsoft.Toolkit.Uwp.UI.Controls { @@ -42,12 +43,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls private AppViewBackButtonVisibility? _previousSystemBackButtonVisibility; private bool _previousNavigationViewBackEnabled; - // Int used because the underlying type is an enum, but we don't have access to the enum - private int _previousNavigationViewBackVisibilty; + private NavigationView.NavigationViewBackButtonVisible _previousNavigationViewBackVisibilty; + private NavigationView.NavigationView _navigationView; private ContentPresenter _detailsPresenter; private VisualStateGroup _selectionStateGroup; private Button _inlineBackButton; - private object _navigationView; private Frame _frame; /// @@ -199,7 +199,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls _frame.Navigating -= OnFrameNavigating; } - _navigationView = this.FindAscendants().FirstOrDefault(p => p.GetType().FullName == "Microsoft.UI.Xaml.Controls.NavigationView"); + _navigationView = this.FindAscendant(); _frame = this.FindAscendant(); if (_frame != null) { @@ -328,8 +328,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls /// private void SetBackButtonVisibility(ListDetailsViewState? previousState = null) { - const int backButtonVisible = 1; - if (DesignMode.DesignModeEnabled) { return; @@ -358,7 +356,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls } else { - SetNavigationViewBackButtonState(backButtonVisible, true); + SetNavigationViewBackButtonState(NavigationView.NavigationViewBackButtonVisible.Visible, true); } } else if (BackButtonBehavior != BackButtonBehavior.Manual) @@ -441,27 +439,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls VisualStateManager.GoToState(this, SelectedItem == null ? noSelectionState : hasSelectionState, animate); } - private void SetNavigationViewBackButtonState(int visible, bool enabled) + private void SetNavigationViewBackButtonState(NavigationView.NavigationViewBackButtonVisible visibility, bool enabled) { if (_navigationView == null) { return; } - var navType = _navigationView.GetType(); - var visibleProperty = navType.GetProperty("IsBackButtonVisible"); - if (visibleProperty != null) - { - _previousNavigationViewBackVisibilty = (int)visibleProperty.GetValue(_navigationView); - visibleProperty.SetValue(_navigationView, visible); - } + _previousNavigationViewBackVisibilty = _navigationView.IsBackButtonVisible; + _navigationView.IsBackButtonVisible = visibility; - var enabledProperty = navType.GetProperty("IsBackEnabled"); - if (enabledProperty != null) - { - _previousNavigationViewBackEnabled = (bool)enabledProperty.GetValue(_navigationView); - enabledProperty.SetValue(_navigationView, enabled); - } + _previousNavigationViewBackEnabled = _navigationView.IsBackEnabled; + _navigationView.IsBackEnabled = enabled; } private void SetDetailsContent()