diff --git a/src/Files.App/Views/LayoutModes/BaseLayout.cs b/src/Files.App/Views/LayoutModes/BaseLayout.cs index 8107b64d7fa1..8d0920af7972 100644 --- a/src/Files.App/Views/LayoutModes/BaseLayout.cs +++ b/src/Files.App/Views/LayoutModes/BaseLayout.cs @@ -188,7 +188,7 @@ public string JumpString } } - protected bool LockPreviewPaneContent { get; set; } + public bool LockPreviewPaneContent { get; set; } private List? selectedItems = new List(); public List? SelectedItems diff --git a/src/Files.App/Views/LayoutModes/IBaseLayout.cs b/src/Files.App/Views/LayoutModes/IBaseLayout.cs index 25744131f23d..4eacf5a90284 100644 --- a/src/Files.App/Views/LayoutModes/IBaseLayout.cs +++ b/src/Files.App/Views/LayoutModes/IBaseLayout.cs @@ -13,22 +13,27 @@ public interface IBaseLayout : IDisposable bool IsMiddleClickToScrollEnabled { get; set; } - public List? SelectedItems { get; } + /// + /// If true, the preview pane is not updated when the selected item is changed. + /// + bool LockPreviewPaneContent { get; set; } - public ListedItem? SelectedItem { get; } + List? SelectedItems { get; } + + ListedItem? SelectedItem { get; } ItemManipulationModel ItemManipulationModel { get; } PreviewPaneViewModel PreviewPaneViewModel { get; } - public SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; } + SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; } - public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; } + DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; } - public BaseLayoutCommandsViewModel? CommandsViewModel { get; } + BaseLayoutCommandsViewModel? CommandsViewModel { get; } - public CommandBarFlyout ItemContextMenuFlyout { get; set; } + CommandBarFlyout ItemContextMenuFlyout { get; set; } - public CommandBarFlyout BaseContextMenuFlyout { get; set; } + CommandBarFlyout BaseContextMenuFlyout { get; set; } } } diff --git a/src/Files.App/Views/PaneHolderPage.xaml.cs b/src/Files.App/Views/PaneHolderPage.xaml.cs index 2d2bb19a4c73..5156163eb822 100644 --- a/src/Files.App/Views/PaneHolderPage.xaml.cs +++ b/src/Files.App/Views/PaneHolderPage.xaml.cs @@ -324,15 +324,33 @@ private void Pane_Loaded(object sender, RoutedEventArgs e) ((UIElement)sender).GotFocus += Pane_GotFocus; } - private void Pane_GotFocus(object sender, RoutedEventArgs e) + private async void Pane_GotFocus(object sender, RoutedEventArgs e) { var isLeftPane = sender == PaneLeft; if (isLeftPane && (PaneRight?.SlimContentPage?.IsItemSelected ?? false)) + { + PaneRight.SlimContentPage.LockPreviewPaneContent = true; PaneRight.SlimContentPage.ItemManipulationModel.ClearSelection(); + PaneRight.SlimContentPage.LockPreviewPaneContent = false; + } else if (!isLeftPane && (PaneLeft?.SlimContentPage?.IsItemSelected ?? false)) + { + PaneLeft.SlimContentPage.LockPreviewPaneContent = true; PaneLeft.SlimContentPage.ItemManipulationModel.ClearSelection(); + PaneLeft.SlimContentPage.LockPreviewPaneContent = false; + } - ActivePane = isLeftPane ? PaneLeft : PaneRight; + var activePane = isLeftPane ? PaneLeft : PaneRight; + if (ActivePane != activePane) + { + ActivePane = activePane; + + if (ActivePane?.SlimContentPage is IBaseLayout page && !page.IsItemSelected) + { + page.PreviewPaneViewModel.IsItemSelected = false; + await page.PreviewPaneViewModel.UpdateSelectedItemPreview(); + } + } } public void Dispose()