Skip to content

Commit 05cd01d

Browse files
committed
Use loaded event to ensure accessability
1 parent c2eca7d commit 05cd01d

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
Expanded="Expander_Expanded"
111111
Header="{DynamicResource plugin_explorer_generalsetting_header}"
112112
IsExpanded="False"
113+
Loaded="GeneralSettingsExpander_Loaded"
113114
Style="{StaticResource CustomExpanderStyle}">
114115

115116
<Grid Margin="20 5 0 5">
@@ -664,6 +665,7 @@
664665
Drop="LbxAccessLinks_OnDrop"
665666
ItemTemplate="{StaticResource ListViewTemplateAccessLinks}"
666667
ItemsSource="{Binding Settings.QuickAccessLinks}"
668+
Loaded="lbxAccessLinks_Loaded"
667669
SelectedItem="{Binding SelectedQuickAccessLink}" />
668670
</Border>
669671

@@ -698,9 +700,11 @@
698700
<!-- Index Search Excluded Paths Expander -->
699701
<Expander
700702
x:Name="ExcludedPathsExpander"
703+
Margin="0"
704+
BorderThickness="0 0 0 0"
701705
Expanded="Expander_Expanded"
702706
Header="{DynamicResource plugin_explorer_indexsearchexcludedpaths_header}"
703-
IsExpanded="False" BorderThickness="0 0 0 0" Margin="0"
707+
IsExpanded="False"
704708
Style="{StaticResource CustomExpanderStyle}">
705709
<Grid Margin="20 5 0 5">
706710
<Grid.RowDefinitions>
@@ -728,6 +732,7 @@
728732
Drop="LbxExcludedPaths_OnDrop"
729733
ItemTemplate="{StaticResource ListViewTemplateAccessLinks}"
730734
ItemsSource="{Binding Settings.IndexSearchExcludedSubdirectoryPaths}"
735+
Loaded="lbxExcludedPaths_Loaded"
731736
SelectedItem="{Binding SelectedIndexSearchExcludedPath}" />
732737
</Border>
733738

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
1515
public partial class ExplorerSettings
1616
{
1717
private readonly SettingsViewModel _viewModel;
18-
private readonly List<Expander> _expanders;
18+
private readonly List<Expander> _expanders = new();
1919

2020
public ExplorerSettings(SettingsViewModel viewModel)
2121
{
@@ -27,26 +27,6 @@ public ExplorerSettings(SettingsViewModel viewModel)
2727
DataContext = viewModel;
2828

2929
ActionKeywordModel.Init(viewModel.Settings);
30-
31-
// Ensure lbxAccessLinks and lbxExcludedPaths are initialized before accessing Items
32-
// This might require Loaded event if they are not immediately available
33-
// For now, assuming they are available after InitializeComponent()
34-
if (lbxAccessLinks != null)
35-
lbxAccessLinks.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
36-
37-
if (lbxExcludedPaths != null)
38-
lbxExcludedPaths.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
39-
40-
_expanders = new List<Expander>
41-
{
42-
GeneralSettingsExpander,
43-
ContextMenuExpander,
44-
PreviewPanelExpander,
45-
EverythingExpander,
46-
ActionKeywordsExpander,
47-
QuickAccessExpander,
48-
ExcludedPathsExpander
49-
};
5030
}
5131

5232
private void AccessLinkDragDrop(string containerName, DragEventArgs e)
@@ -124,5 +104,30 @@ private void Expander_Expanded(object sender, RoutedEventArgs e)
124104
}
125105
}
126106
}
107+
108+
private void lbxAccessLinks_Loaded(object sender, RoutedEventArgs e)
109+
{
110+
lbxAccessLinks.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
111+
}
112+
113+
private void lbxExcludedPaths_Loaded(object sender, RoutedEventArgs e)
114+
{
115+
lbxExcludedPaths.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
116+
}
117+
118+
private void GeneralSettingsExpander_Loaded(object sender, RoutedEventArgs e)
119+
{
120+
var expanders = new List<Expander>
121+
{
122+
GeneralSettingsExpander,
123+
ContextMenuExpander,
124+
PreviewPanelExpander,
125+
EverythingExpander,
126+
ActionKeywordsExpander,
127+
QuickAccessExpander,
128+
ExcludedPathsExpander
129+
};
130+
_expanders.AddRange(expanders);
131+
}
127132
}
128133
}

0 commit comments

Comments
 (0)