@@ -59,7 +59,6 @@ protected override void HookEvents()
59
59
ItemManipulationModel . ScrollIntoViewInvoked += ItemManipulationModel_ScrollIntoViewInvoked ;
60
60
ItemManipulationModel . RefreshItemThumbnailInvoked += ItemManipulationModel_RefreshItemThumbnail ;
61
61
ItemManipulationModel . RefreshItemsThumbnailInvoked += ItemManipulationModel_RefreshItemsThumbnail ;
62
-
63
62
}
64
63
65
64
private void ItemManipulationModel_RefreshItemsThumbnail ( object ? sender , EventArgs e )
@@ -134,7 +133,10 @@ private void ItemManipulationModel_SelectAllItemsInvoked(object? sender, EventAr
134
133
135
134
private void ItemManipulationModel_FocusFileListInvoked ( object ? sender , EventArgs e )
136
135
{
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 ) ;
138
140
}
139
141
140
142
private void ZoomIn ( object ? sender , GroupOption option )
@@ -326,7 +328,7 @@ private void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
326
328
private void RenameTextBox_LostFocus ( object sender , RoutedEventArgs e )
327
329
{
328
330
// 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 ) )
330
332
return ;
331
333
332
334
TextBox textBox = ( TextBox ) e . OriginalSource ;
@@ -373,7 +375,7 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
373
375
{
374
376
var ctrlPressed = InputKeyboardSource . GetKeyStateForCurrentThread ( VirtualKey . Control ) . HasFlag ( CoreVirtualKeyStates . Down ) ;
375
377
var shiftPressed = InputKeyboardSource . GetKeyStateForCurrentThread ( VirtualKey . Shift ) . HasFlag ( CoreVirtualKeyStates . Down ) ;
376
- var focusedElement = FocusManager . GetFocusedElement ( ) as FrameworkElement ;
378
+ var focusedElement = FocusManager . GetFocusedElement ( XamlRoot ) as FrameworkElement ;
377
379
var isFooterFocused = focusedElement is HyperlinkButton ;
378
380
379
381
if ( e . Key == VirtualKey . Enter && ! isFooterFocused && ! e . KeyStatus . IsMenuKeyDown )
@@ -412,12 +414,12 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
412
414
else if ( e . KeyStatus . IsMenuKeyDown && ( e . Key == VirtualKey . Left || e . Key == VirtualKey . Right || e . Key == VirtualKey . Up ) )
413
415
{
414
416
// Unfocus the GridView so keyboard shortcut can be handled
415
- NavToolbar ? . Focus ( FocusState . Pointer ) ;
417
+ this . Focus ( FocusState . Pointer ) ;
416
418
}
417
419
else if ( e . KeyStatus . IsMenuKeyDown && shiftPressed && e . Key == VirtualKey . Add )
418
420
{
419
421
// Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")
420
- NavToolbar ? . Focus ( FocusState . Pointer ) ;
422
+ this . Focus ( FocusState . Pointer ) ;
421
423
}
422
424
else if ( e . Key == VirtualKey . Up || e . Key == VirtualKey . Down )
423
425
{
@@ -438,7 +440,7 @@ protected override void Page_CharacterReceived(UIElement sender, CharacterReceiv
438
440
if ( ParentShellPageInstance . CurrentPageType == typeof ( GridViewBrowser ) && ! IsRenamingItem )
439
441
{
440
442
// Don't block the various uses of enter key (key 13)
441
- var focusedElement = ( FrameworkElement ) FocusManager . GetFocusedElement ( ) ;
443
+ var focusedElement = ( FrameworkElement ) FocusManager . GetFocusedElement ( XamlRoot ) ;
442
444
if ( InputKeyboardSource . GetKeyStateForCurrentThread ( VirtualKey . Enter ) == CoreVirtualKeyStates . Down
443
445
|| focusedElement is Button
444
446
|| focusedElement is TextBox
0 commit comments