Skip to content

Commit

Permalink
Fix issue where setting IsPaneButtonVisible on NavigationView could e…
Browse files Browse the repository at this point in the history
…nd up in faulty rendering of pane toggle button (#6780)

* Add test ui

* Fix issue with margin not updating correctly
  • Loading branch information
marcelwgn authored Mar 9, 2022
1 parent 5bb3b05 commit 4e2990d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions dev/NavigationView/NavigationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4043,6 +4043,7 @@ void NavigationView::OnPropertyChanged(const winrt::DependencyPropertyChangedEve
UpdatePaneTitleFrameworkElementParents();
UpdateBackAndCloseButtonsVisibility();
UpdatePaneToggleButtonVisibility();
UpdateTitleBarPadding();
UpdateVisualState();
}
else if (property == s_IsSettingsVisibleProperty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<StackPanel>
<StackPanel Orientation="Horizontal">
<muxcontrols:NavigationView x:Name="NavView" AutomationProperties.Name="NavView" AutomationProperties.AutomationId="NavView"
IsBackEnabled="True" Header="LeftMinimal" PaneDisplayMode="LeftMinimal" Margin="10,0">
IsBackEnabled="True" Header="LeftMinimal" PaneDisplayMode="LeftMinimal" Margin="10,0" IsPaneToggleButtonVisible="False">
<StackPanel>
<TextBlock x:Name="NavViewActiveVisualStatesResult" AutomationProperties.Name="NavViewActiveVisualStatesResult"/>
<Button x:Name="GetNavViewActiveVisualStates" AutomationProperties.Name="GetNavViewActiveVisualStates" Content="GetNavViewActiveVisualStates" Click="GetNavViewActiveVisualStates_Click"/>
Expand Down Expand Up @@ -43,6 +43,7 @@
IsChecked="{Binding IsPaneOpen, ElementName=NavViewAuto, Mode=TwoWay}"
x:Name="IsAutoPaneOpenCheckBox"
AutomationProperties.Name="IsPaneOpenCheckBox" >Toggle auto pane open</CheckBox>
<Button Content="Toggle pane open and button visible" Click="TogglePaneOpenButton_Click"/>
</StackPanel>
</StackPanel>
</local:TestPage>
15 changes: 15 additions & 0 deletions dev/NavigationView/TestUI/Common/NavigationViewMinimalPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using Microsoft.UI.Xaml.Controls;
using Windows.UI.Xaml;

namespace MUXControlsTestApp
Expand All @@ -16,5 +17,19 @@ private void GetNavViewActiveVisualStates_Click(object sender, RoutedEventArgs e
var visualstates = Utilities.VisualStateHelper.GetCurrentVisualStateName(NavView);
NavViewActiveVisualStatesResult.Text = string.Join(",", visualstates);
}

private void TogglePaneOpenButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
if (NavView.IsPaneToggleButtonVisible)
{
NavView.PaneDisplayMode = NavigationViewPaneDisplayMode.Left;
NavView.IsPaneToggleButtonVisible = false;
}
else
{
NavView.PaneDisplayMode = NavigationViewPaneDisplayMode.LeftMinimal;
NavView.IsPaneToggleButtonVisible = true;
}
}
}
}

0 comments on commit 4e2990d

Please sign in to comment.