Skip to content

Commit 6fb9ff6

Browse files
committed
Remove code that removed focus visual in SelectionFollowsFocus mode (microsoft/microsoft-ui-xaml#3190)
1 parent d91ea11 commit 6fb9ff6

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

ModernWpf.Controls/NavigationView/NavigationView.cs

-46
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,6 @@ public override void OnApplyTemplate()
724724
UpdatePaneTabFocusNavigation();
725725
UpdateBackAndCloseButtonsVisibility();
726726
UpdateSingleSelectionFollowsFocusTemplateSetting();
727-
UpdateNavigationViewUseSystemVisual();
728727
UpdatePaneVisibility();
729728
UpdateVisualState();
730729
UpdatePaneTitleMargins();
@@ -1266,11 +1265,6 @@ int init()
12661265
}
12671266
nvi.PropagateDepthToChildren(childDepth);
12681267

1269-
if (ir != m_topNavRepeaterOverflowView)
1270-
{
1271-
nvibImpl.UseSystemFocusVisuals = ShouldShowFocusVisual();
1272-
}
1273-
12741268
// Register for item events
12751269
InputHelper.AddTappedHandler(nvi, OnNavigationViewItemTapped);
12761270
nvi.KeyDown += OnNavigationViewItemKeyDown;
@@ -3372,45 +3366,6 @@ void UpdateLeftNavigationOnlyVisualState(bool useTransitions)
33723366
VisualStateManager.GoToState(this, isToggleButtonVisible ? "TogglePaneButtonVisible" : "TogglePaneButtonCollapsed", false /*useTransitions*/);
33733367
}
33743368

3375-
void UpdateNavigationViewUseSystemVisual()
3376-
{
3377-
if (SharedHelpers.IsRS1OrHigher() && !ShouldPreserveNavigationViewRS4Behavior() && m_appliedTemplate)
3378-
{
3379-
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_leftNavRepeater, ShouldShowFocusVisual());
3380-
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_leftNavFooterMenuRepeater, ShouldShowFocusVisual());
3381-
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_topNavRepeater, ShouldShowFocusVisual());
3382-
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_topNavFooterMenuRepeater, ShouldShowFocusVisual());
3383-
}
3384-
}
3385-
3386-
bool ShouldShowFocusVisual()
3387-
{
3388-
return SelectionFollowsFocus == NavigationViewSelectionFollowsFocus.Disabled;
3389-
}
3390-
3391-
void PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(ItemsRepeater ir, bool showFocusVisual)
3392-
{
3393-
if (ir != null)
3394-
{
3395-
if (ir.ItemsSourceView is { } itemsSourceView)
3396-
{
3397-
var numberOfItems = itemsSourceView.Count;
3398-
for (int i = 0; i < numberOfItems; i++)
3399-
{
3400-
if (ir.TryGetElement(i) is { } nvib)
3401-
{
3402-
if (nvib is NavigationViewItem nvi)
3403-
{
3404-
var nviImpl = nvi;
3405-
nviImpl.UseSystemFocusVisuals = showFocusVisual;
3406-
}
3407-
}
3408-
3409-
}
3410-
}
3411-
}
3412-
}
3413-
34143369
void InvalidateTopNavPrimaryLayout()
34153370
{
34163371
if (m_appliedTemplate && IsTopNavigationView())
@@ -4007,7 +3962,6 @@ void PropertyChanged(DependencyPropertyChangedEventArgs args)
40073962
else if (property == SelectionFollowsFocusProperty)
40083963
{
40093964
UpdateSingleSelectionFollowsFocusTemplateSetting();
4010-
UpdateNavigationViewUseSystemVisual();
40113965
}
40123966
else if (property == IsPaneToggleButtonVisibleProperty)
40133967
{

ModernWpf.Controls/NavigationView/NavigationView.xaml

-4
Original file line numberDiff line numberDiff line change
@@ -1377,10 +1377,6 @@
13771377
</Setter>
13781378
</Style>
13791379

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

0 commit comments

Comments
 (0)