diff --git a/src/Files.App/ViewModels/FolderSettingsViewModel.cs b/src/Files.App/ViewModels/FolderSettingsViewModel.cs index 9f11e87157db..f48127e9e3b5 100644 --- a/src/Files.App/ViewModels/FolderSettingsViewModel.cs +++ b/src/Files.App/ViewModels/FolderSettingsViewModel.cs @@ -94,11 +94,14 @@ public bool IsLayoutModeChanging set => SetProperty(ref isLayoutModeChanging, value); } - public Type GetLayoutType(string folderPath) + public Type GetLayoutType(string folderPath, bool changeLayoutMode = true) { var prefsForPath = GetLayoutPreferencesForPath(folderPath); - IsLayoutModeChanging = LayoutPreference.LayoutMode != prefsForPath.LayoutMode; - LayoutPreference = prefsForPath; + if (changeLayoutMode) + { + IsLayoutModeChanging = LayoutPreference.LayoutMode != prefsForPath.LayoutMode; + LayoutPreference = prefsForPath; + } return (prefsForPath.LayoutMode) switch { diff --git a/src/Files.App/Views/BaseShellPage.cs b/src/Files.App/Views/BaseShellPage.cs index 11dde8e3f2ca..71f5f506f64c 100644 --- a/src/Files.App/Views/BaseShellPage.cs +++ b/src/Files.App/Views/BaseShellPage.cs @@ -503,9 +503,10 @@ public void ResetNavigationStackLayoutMode() { foreach (PageStackEntry entry in ItemDisplay.BackStack.ToList()) { - if (entry.Parameter is NavigationArguments args) + if (entry.Parameter is NavigationArguments args && + args.NavPathParam is not null and not "Home") { - var correctPageType = FolderSettings.GetLayoutType(args.NavPathParam); + var correctPageType = FolderSettings.GetLayoutType(args.NavPathParam, false); if (!entry.SourcePageType.Equals(correctPageType)) { int index = ItemDisplay.BackStack.IndexOf(entry); @@ -518,9 +519,10 @@ public void ResetNavigationStackLayoutMode() foreach (PageStackEntry entry in ItemDisplay.ForwardStack.ToList()) { - if (entry.Parameter is NavigationArguments args) + if (entry.Parameter is NavigationArguments args && + args.NavPathParam is not null and not "Home") { - var correctPageType = FolderSettings.GetLayoutType(args.NavPathParam); + var correctPageType = FolderSettings.GetLayoutType(args.NavPathParam, false); if (!entry.SourcePageType.Equals(correctPageType)) { int index = ItemDisplay.ForwardStack.IndexOf(entry);