From 6614771c3dfafd8a32d4573303f8ff479eea9477 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 6 Jun 2025 17:03:20 +0800 Subject: [PATCH] Move initialization to constructor --- .../Views/ExplorerSettings.xaml | 1 - .../Views/ExplorerSettings.xaml.cs | 28 ++++++++----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index 070820a0d..b81c3cac3 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -108,7 +108,6 @@ Expanded="Expander_Expanded" Header="{DynamicResource plugin_explorer_generalsetting_header}" IsExpanded="False" - Loaded="GeneralSettingsExpander_Loaded" Style="{StaticResource CustomExpanderStyle}"> diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs index e82c10ae2..2c50f1c6f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs @@ -15,7 +15,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views public partial class ExplorerSettings { private readonly SettingsViewModel _viewModel; - private readonly List _expanders = new(); + private readonly List _expanders; public ExplorerSettings(SettingsViewModel viewModel) { @@ -27,6 +27,17 @@ namespace Flow.Launcher.Plugin.Explorer.Views DataContext = viewModel; ActionKeywordModel.Init(viewModel.Settings); + + _expanders = new List + { + GeneralSettingsExpander, + ContextMenuExpander, + PreviewPanelExpander, + EverythingExpander, + ActionKeywordsExpander, + QuickAccessExpander, + ExcludedPathsExpander + }; } private void AccessLinkDragDrop(string containerName, DragEventArgs e) @@ -114,20 +125,5 @@ namespace Flow.Launcher.Plugin.Explorer.Views { lbxExcludedPaths.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending)); } - - private void GeneralSettingsExpander_Loaded(object sender, RoutedEventArgs e) - { - var expanders = new List - { - GeneralSettingsExpander, - ContextMenuExpander, - PreviewPanelExpander, - EverythingExpander, - ActionKeywordsExpander, - QuickAccessExpander, - ExcludedPathsExpander - }; - _expanders.AddRange(expanders); - } } }