diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs index ef20f70b47..517060f87d 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs @@ -58,12 +58,6 @@ public sealed partial class DockViewModel : IDisposable, SetupBands(_settings.StartBands, StartItems); SetupBands(_settings.CenterBands, CenterItems); SetupBands(_settings.EndBands, EndItems); - - // Initialize properties on BG thread - Task.Run(() => - { - InitializeAllBands(); - }); } private void SetupBands( @@ -94,13 +88,27 @@ public sealed partial class DockViewModel : IDisposable, var beforeCount = target.Count; var afterCount = newBands.Count; + List removed = new(); DoOnUiThread(() => { - ListHelpers.InPlaceUpdateList(target, newBands, out var removed); + ListHelpers.InPlaceUpdateList(target, newBands, out removed); var isStartBand = target == StartItems; var label = isStartBand ? "Start bands:" : "End bands:"; Logger.LogDebug($"{label} ({beforeCount}) -> ({afterCount}), Removed {removed?.Count ?? 0} items"); }); + + // Initialize properties on BG thread + Task.Run(() => + { + foreach (var band in newBands) + { + band.SafeInitializePropertiesSynchronous(); + } + }); + foreach (var removedItem in removed) + { + removedItem.SafeCleanup(); + } } public void Dispose() @@ -612,24 +620,6 @@ public sealed partial class DockViewModel : IDisposable, }; } } - - private void InitializeAllBands() - { - foreach (var band in StartItems) - { - band.SafeInitializePropertiesSynchronous(); - } - - foreach (var band in CenterItems) - { - band.SafeInitializePropertiesSynchronous(); - } - - foreach (var band in EndItems) - { - band.SafeInitializePropertiesSynchronous(); - } - } } #pragma warning restore SA1402 // File may only contain a single type diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml index 3f2b491b34..1431dc1e38 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml @@ -37,8 +37,6 @@ EmptyValue="Collapsed" NotEmptyValue="Visible" /> - - diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml index b554e01418..0fa173197e 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml @@ -8,7 +8,6 @@ xmlns:help="using:Microsoft.CmdPal.UI.Helpers" xmlns:local="using:Microsoft.CmdPal.UI.Dock" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:toolkit="using:CommunityToolkit.WinUI.Controls" xmlns:vm="using:Microsoft.CmdPal.UI.ViewModels" xmlns:winuiex="using:WinUIEx" Title="PowerDock" diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml index 2833d27ee1..7320b1a0ae 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml @@ -103,7 +103,9 @@ - + - -