@@ -19,6 +19,7 @@ public sealed partial class ShellPanesPage : Page, IShellPanesPage, ITabBarItemC
1919 // Dependency injections
2020
2121 private IGeneralSettingsService GeneralSettingsService { get ; } = Ioc . Default . GetRequiredService < IGeneralSettingsService > ( ) ;
22+ private ILayoutSettingsService LayoutSettingsService { get ; } = Ioc . Default . GetRequiredService < ILayoutSettingsService > ( ) ;
2223 private AppModel AppModel { get ; } = Ioc . Default . GetRequiredService < AppModel > ( ) ;
2324
2425 // Constants
@@ -357,13 +358,10 @@ public void FocusOtherPane()
357358 }
358359
359360 /// <inheritdoc/>
360- public void UpdatePanesLayout ( bool inlcudeActive = true )
361+ public void UpdatePanesLayout ( )
361362 {
362- if ( GetPane ( 0 ) is IShellPage leftPane && ( inlcudeActive || leftPane != ActivePane ) )
363- UpdatePaneLayout ( leftPane ) ;
364-
365- if ( GetPane ( 1 ) is IShellPage rightPane && ( inlcudeActive || rightPane != ActivePane ) )
366- UpdatePaneLayout ( rightPane ) ;
363+ foreach ( var pane in GetPanes ( ) )
364+ UpdatePaneLayout ( pane ) ;
367365 }
368366
369367 // Private methods
@@ -469,6 +467,9 @@ RootGrid.ColumnDefinitions.Count is 0
469467 // Focus
470468 ActivePane = GetPane ( GetPaneCount ( ) - 1 ) ;
471469
470+ UnHookLayoutUpdateRequiredEvent ( ) ;
471+ HookLayoutUpdateRequiredEvent ( ) ;
472+
472473 NotifyPropertyChanged ( nameof ( IsMultiPaneActive ) ) ;
473474 }
474475
@@ -533,6 +534,7 @@ private void RemovePane(int index = -1)
533534 }
534535
535536 Pane_ContentChanged ( null , null ! ) ;
537+ UnHookLayoutUpdateRequiredEvent ( ) ;
536538 NotifyPropertyChanged ( nameof ( IsMultiPaneActive ) ) ;
537539 }
538540
@@ -562,6 +564,18 @@ private void SetShadow()
562564 }
563565 }
564566
567+ private void HookLayoutUpdateRequiredEvent ( )
568+ {
569+ foreach ( var pane in GetPanes ( ) )
570+ pane . FolderSettings . LayoutPreferencesUpdateRequired += FolderSettings_LayoutPreferencesUpdateRequired ;
571+ }
572+
573+ private void UnHookLayoutUpdateRequiredEvent ( )
574+ {
575+ foreach ( var pane in GetPanes ( ) )
576+ pane . FolderSettings . LayoutPreferencesUpdateRequired -= FolderSettings_LayoutPreferencesUpdateRequired ;
577+ }
578+
565579 // Override methods
566580
567581 protected override void OnNavigatedTo ( NavigationEventArgs eventArgs )
@@ -740,6 +754,24 @@ private void Sizer_ManipulationCompleted(object sender, ManipulationCompletedRou
740754 this . ChangeCursor ( InputSystemCursor . Create ( InputSystemCursorShape . Arrow ) ) ;
741755 }
742756
757+ private void FolderSettings_LayoutPreferencesUpdateRequired ( object ? sender , LayoutPreferenceEventArgs e )
758+ {
759+ var currentPath = ActivePane ? . TabBarItemParameter ? . NavigationParameter as string ;
760+ if ( string . IsNullOrEmpty ( currentPath ) )
761+ return ;
762+
763+ foreach ( var pane in GetPanes ( ) )
764+ {
765+ if ( pane != ActivePane &&
766+ ( LayoutSettingsService . SyncFolderPreferencesAcrossDirectories ||
767+ pane . TabBarItemParameter ? . NavigationParameter is string path &&
768+ path . Equals ( currentPath , StringComparison . OrdinalIgnoreCase ) ) )
769+ {
770+ UpdatePaneLayout ( pane ) ;
771+ }
772+ }
773+ }
774+
743775 private void NotifyPropertyChanged ( [ CallerMemberName ] string propertyName = "" )
744776 {
745777 PropertyChanged ? . Invoke ( this , new PropertyChangedEventArgs ( propertyName ) ) ;
@@ -759,6 +791,7 @@ public void Dispose()
759791 pane . GotFocus -= Pane_GotFocus ;
760792 pane . RightTapped -= Pane_RightTapped ;
761793 pane . PointerPressed -= Pane_PointerPressed ;
794+ pane . FolderSettings . LayoutPreferencesUpdateRequired -= FolderSettings_LayoutPreferencesUpdateRequired ;
762795 pane . Dispose ( ) ;
763796 }
764797
0 commit comments