diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index ca395fc5e..451d7afb2 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -110,6 +110,7 @@ Expanded="Expander_Expanded" Header="{DynamicResource plugin_explorer_generalsetting_header}" IsExpanded="False" + Loaded="GeneralSettingsExpander_Loaded" Style="{StaticResource CustomExpanderStyle}"> @@ -664,6 +665,7 @@ Drop="LbxAccessLinks_OnDrop" ItemTemplate="{StaticResource ListViewTemplateAccessLinks}" ItemsSource="{Binding Settings.QuickAccessLinks}" + Loaded="lbxAccessLinks_Loaded" SelectedItem="{Binding SelectedQuickAccessLink}" /> @@ -698,9 +700,11 @@ @@ -728,6 +732,7 @@ Drop="LbxExcludedPaths_OnDrop" ItemTemplate="{StaticResource ListViewTemplateAccessLinks}" ItemsSource="{Binding Settings.IndexSearchExcludedSubdirectoryPaths}" + Loaded="lbxExcludedPaths_Loaded" SelectedItem="{Binding SelectedIndexSearchExcludedPath}" /> diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs index bb52612e4..e82c10ae2 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; + private readonly List _expanders = new(); public ExplorerSettings(SettingsViewModel viewModel) { @@ -27,26 +27,6 @@ namespace Flow.Launcher.Plugin.Explorer.Views DataContext = viewModel; ActionKeywordModel.Init(viewModel.Settings); - - // Ensure lbxAccessLinks and lbxExcludedPaths are initialized before accessing Items - // This might require Loaded event if they are not immediately available - // For now, assuming they are available after InitializeComponent() - if (lbxAccessLinks != null) - lbxAccessLinks.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending)); - - if (lbxExcludedPaths != null) - lbxExcludedPaths.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending)); - - _expanders = new List - { - GeneralSettingsExpander, - ContextMenuExpander, - PreviewPanelExpander, - EverythingExpander, - ActionKeywordsExpander, - QuickAccessExpander, - ExcludedPathsExpander - }; } private void AccessLinkDragDrop(string containerName, DragEventArgs e) @@ -124,5 +104,30 @@ namespace Flow.Launcher.Plugin.Explorer.Views } } } + + private void lbxAccessLinks_Loaded(object sender, RoutedEventArgs e) + { + lbxAccessLinks.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending)); + } + + private void lbxExcludedPaths_Loaded(object sender, RoutedEventArgs e) + { + 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); + } } }