Skip to content

Commit

Permalink
Remove code that removed focus visual in SelectionFollowsFocus mode (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed Sep 11, 2020
1 parent d91ea11 commit 6fb9ff6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 50 deletions.
46 changes: 0 additions & 46 deletions ModernWpf.Controls/NavigationView/NavigationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,6 @@ public override void OnApplyTemplate()
UpdatePaneTabFocusNavigation();
UpdateBackAndCloseButtonsVisibility();
UpdateSingleSelectionFollowsFocusTemplateSetting();
UpdateNavigationViewUseSystemVisual();
UpdatePaneVisibility();
UpdateVisualState();
UpdatePaneTitleMargins();
Expand Down Expand Up @@ -1266,11 +1265,6 @@ int init()
}
nvi.PropagateDepthToChildren(childDepth);

if (ir != m_topNavRepeaterOverflowView)
{
nvibImpl.UseSystemFocusVisuals = ShouldShowFocusVisual();
}

// Register for item events
InputHelper.AddTappedHandler(nvi, OnNavigationViewItemTapped);
nvi.KeyDown += OnNavigationViewItemKeyDown;
Expand Down Expand Up @@ -3372,45 +3366,6 @@ void UpdateLeftNavigationOnlyVisualState(bool useTransitions)
VisualStateManager.GoToState(this, isToggleButtonVisible ? "TogglePaneButtonVisible" : "TogglePaneButtonCollapsed", false /*useTransitions*/);
}

void UpdateNavigationViewUseSystemVisual()
{
if (SharedHelpers.IsRS1OrHigher() && !ShouldPreserveNavigationViewRS4Behavior() && m_appliedTemplate)
{
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_leftNavRepeater, ShouldShowFocusVisual());
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_leftNavFooterMenuRepeater, ShouldShowFocusVisual());
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_topNavRepeater, ShouldShowFocusVisual());
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_topNavFooterMenuRepeater, ShouldShowFocusVisual());
}
}

bool ShouldShowFocusVisual()
{
return SelectionFollowsFocus == NavigationViewSelectionFollowsFocus.Disabled;
}

void PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(ItemsRepeater ir, bool showFocusVisual)
{
if (ir != null)
{
if (ir.ItemsSourceView is { } itemsSourceView)
{
var numberOfItems = itemsSourceView.Count;
for (int i = 0; i < numberOfItems; i++)
{
if (ir.TryGetElement(i) is { } nvib)
{
if (nvib is NavigationViewItem nvi)
{
var nviImpl = nvi;
nviImpl.UseSystemFocusVisuals = showFocusVisual;
}
}

}
}
}
}

void InvalidateTopNavPrimaryLayout()
{
if (m_appliedTemplate && IsTopNavigationView())
Expand Down Expand Up @@ -4007,7 +3962,6 @@ void PropertyChanged(DependencyPropertyChangedEventArgs args)
else if (property == SelectionFollowsFocusProperty)
{
UpdateSingleSelectionFollowsFocusTemplateSetting();
UpdateNavigationViewUseSystemVisual();
}
else if (property == IsPaneToggleButtonVisibleProperty)
{
Expand Down
4 changes: 0 additions & 4 deletions ModernWpf.Controls/NavigationView/NavigationView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1377,10 +1377,6 @@
</Setter>
</Style>

<!--Note: Even though UseSystemFocusVisuals is set to True here in the Style, and because
bindings in Styles are only evaluated once, we were unable to bring a TemplateSettings.UseSystemFocusVisuals
to handle the removal of the focus rect when SelectionFollowsFocus is enabled. Therefore, that has
been done in code and it's updated whenever SelectionFollowsFocus is changed.-->
<Style TargetType="local:NavigationViewItem">
<Setter Property="Foreground" Value="{DynamicResource NavigationViewItemForeground}" />
<Setter Property="Background" Value="{DynamicResource NavigationViewItemBackground}" />
Expand Down

0 comments on commit 6fb9ff6

Please sign in to comment.