@@ -59,7 +59,6 @@ protected override void HookEvents()
5959 ItemManipulationModel . ScrollIntoViewInvoked += ItemManipulationModel_ScrollIntoViewInvoked ;
6060 ItemManipulationModel . RefreshItemThumbnailInvoked += ItemManipulationModel_RefreshItemThumbnail ;
6161 ItemManipulationModel . RefreshItemsThumbnailInvoked += ItemManipulationModel_RefreshItemsThumbnail ;
62-
6362 }
6463
6564 private void ItemManipulationModel_RefreshItemsThumbnail ( object ? sender , EventArgs e )
@@ -134,7 +133,10 @@ private void ItemManipulationModel_SelectAllItemsInvoked(object? sender, EventAr
134133
135134 private void ItemManipulationModel_FocusFileListInvoked ( object ? sender , EventArgs e )
136135 {
137- FileList . Focus ( FocusState . Programmatic ) ;
136+ var focusedElement = ( FrameworkElement ) FocusManager . GetFocusedElement ( XamlRoot ) ;
137+ var isFileListFocused = DependencyObjectHelpers . FindParent < ListViewBase > ( focusedElement ) == FileList ;
138+ if ( ! isFileListFocused )
139+ FileList . Focus ( FocusState . Programmatic ) ;
138140 }
139141
140142 private void ZoomIn ( object ? sender , GroupOption option )
@@ -326,7 +328,7 @@ private void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
326328 private void RenameTextBox_LostFocus ( object sender , RoutedEventArgs e )
327329 {
328330 // This check allows the user to use the text box context menu without ending the rename
329- if ( ( FocusManager . GetFocusedElement ( ) is AppBarButton or Popup ) )
331+ if ( ( FocusManager . GetFocusedElement ( XamlRoot ) is AppBarButton or Popup ) )
330332 return ;
331333
332334 TextBox textBox = ( TextBox ) e . OriginalSource ;
@@ -373,7 +375,7 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
373375 {
374376 var ctrlPressed = InputKeyboardSource . GetKeyStateForCurrentThread ( VirtualKey . Control ) . HasFlag ( CoreVirtualKeyStates . Down ) ;
375377 var shiftPressed = InputKeyboardSource . GetKeyStateForCurrentThread ( VirtualKey . Shift ) . HasFlag ( CoreVirtualKeyStates . Down ) ;
376- var focusedElement = FocusManager . GetFocusedElement ( ) as FrameworkElement ;
378+ var focusedElement = FocusManager . GetFocusedElement ( XamlRoot ) as FrameworkElement ;
377379 var isFooterFocused = focusedElement is HyperlinkButton ;
378380
379381 if ( e . Key == VirtualKey . Enter && ! isFooterFocused && ! e . KeyStatus . IsMenuKeyDown )
@@ -412,12 +414,12 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
412414 else if ( e . KeyStatus . IsMenuKeyDown && ( e . Key == VirtualKey . Left || e . Key == VirtualKey . Right || e . Key == VirtualKey . Up ) )
413415 {
414416 // Unfocus the GridView so keyboard shortcut can be handled
415- NavToolbar ? . Focus ( FocusState . Pointer ) ;
417+ this . Focus ( FocusState . Pointer ) ;
416418 }
417419 else if ( e . KeyStatus . IsMenuKeyDown && shiftPressed && e . Key == VirtualKey . Add )
418420 {
419421 // Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")
420- NavToolbar ? . Focus ( FocusState . Pointer ) ;
422+ this . Focus ( FocusState . Pointer ) ;
421423 }
422424 else if ( e . Key == VirtualKey . Up || e . Key == VirtualKey . Down )
423425 {
@@ -438,7 +440,7 @@ protected override void Page_CharacterReceived(UIElement sender, CharacterReceiv
438440 if ( ParentShellPageInstance . CurrentPageType == typeof ( GridViewBrowser ) && ! IsRenamingItem )
439441 {
440442 // Don't block the various uses of enter key (key 13)
441- var focusedElement = ( FrameworkElement ) FocusManager . GetFocusedElement ( ) ;
443+ var focusedElement = ( FrameworkElement ) FocusManager . GetFocusedElement ( XamlRoot ) ;
442444 if ( InputKeyboardSource . GetKeyStateForCurrentThread ( VirtualKey . Enter ) == CoreVirtualKeyStates . Down
443445 || focusedElement is Button
444446 || focusedElement is TextBox
0 commit comments