Skip to content

Commit

Permalink
Navview fix issue with compact pane length not being behaving correct…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed Apr 30, 2020
1 parent 91c3d0d commit 7f3b825
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ModernWpf.Controls/NavigationView/NavigationView.cs
Expand Up @@ -3759,6 +3759,8 @@ void OnLoaded(object sender, RoutedEventArgs args)
coreTitleBar.LayoutMetricsChanged += OnTitleBarMetricsChanged;
coreTitleBar.IsVisibleChanged += OnTitleBarIsVisibleChanged;
}
// Update pane buttons now since we the CompactPaneLength is actually known now.
UpdatePaneButtonsWidths();
}

void OnIsPaneOpenChanged()
Expand Down
Expand Up @@ -56,7 +56,7 @@
IsChecked="{Binding IsPaneVisible, ElementName=NavView, Mode=TwoWay}"
Margin="5"/>

<ComboBoxEx x:Name="CompactPaneLength" Header="Compact Pane Length" AutomationProperties.Name="CompactPaneLenghtComboBox"
<ComboBoxEx x:Name="CompactPaneLength" Header="Compact Pane Length" AutomationProperties.Name="CompactPaneLengthComboBox"
SelectionChanged="CompactPaneLength_SelectionChanged" Margin="5">
<ComboBoxItem Content="0" Tag="0"/>
<ComboBoxItem Content="40" Tag="40" IsSelected="True"/>
Expand Down
Expand Up @@ -19,6 +19,8 @@ public sealed partial class NavigationViewCompactPaneLengthTestPage : TestPage
public NavigationViewCompactPaneLengthTestPage()
{
this.InitializeComponent();

NavView.CompactPaneLength = 96;
}

private void CompactPaneLength_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down Expand Up @@ -73,7 +75,8 @@ private void BackButtonEnabledCheckbox_Unchecked(object sender, RoutedEventArgs
private void CheckMenuItemsOffset_Click(object sender, RoutedEventArgs e)
{
bool allCorrect = true;
foreach(var item in NavView.MenuItems)

foreach (var item in NavView.MenuItems)
{
if(item as NavigationViewItem == null)
{
Expand All @@ -85,6 +88,23 @@ private void CheckMenuItemsOffset_Click(object sender, RoutedEventArgs e)
allCorrect = false;
}
}

var rootgrid = VisualTreeHelper.GetChild(NavView, 0);
var paneToggleButtonGrid = VisualTreeHelper.GetChild(rootgrid, 0);
var buttonHolderGrid = VisualTreeHelper.GetChild(paneToggleButtonGrid, 1);
var backButton = VisualTreeHelper.GetChild(buttonHolderGrid, 0) as Button;
var togglePaneButton = VisualTreeHelper.GetChild(buttonHolderGrid, 2) as Button;

if (Math.Abs(backButton.ActualWidth - NavView.CompactPaneLength) > double.Epsilon)
{
allCorrect = false;
}

if (Math.Abs(togglePaneButton.ActualWidth - NavView.CompactPaneLength) > double.Epsilon)
{
allCorrect = false;
}

MenuItemsCorrectOffset.IsChecked = allCorrect;

}
Expand Down

0 comments on commit 7f3b825

Please sign in to comment.