Use loaded event to ensure accessability

This commit is contained in:
Jack251970 2025-06-06 16:20:43 +08:00
parent c2eca7dc39
commit 05cd01d1d6
2 changed files with 32 additions and 22 deletions

View file

@ -110,6 +110,7 @@
Expanded="Expander_Expanded"
Header="{DynamicResource plugin_explorer_generalsetting_header}"
IsExpanded="False"
Loaded="GeneralSettingsExpander_Loaded"
Style="{StaticResource CustomExpanderStyle}">
<Grid Margin="20 5 0 5">
@ -664,6 +665,7 @@
Drop="LbxAccessLinks_OnDrop"
ItemTemplate="{StaticResource ListViewTemplateAccessLinks}"
ItemsSource="{Binding Settings.QuickAccessLinks}"
Loaded="lbxAccessLinks_Loaded"
SelectedItem="{Binding SelectedQuickAccessLink}" />
</Border>
@ -698,9 +700,11 @@
<!-- Index Search Excluded Paths Expander -->
<Expander
x:Name="ExcludedPathsExpander"
Margin="0"
BorderThickness="0 0 0 0"
Expanded="Expander_Expanded"
Header="{DynamicResource plugin_explorer_indexsearchexcludedpaths_header}"
IsExpanded="False" BorderThickness="0 0 0 0" Margin="0"
IsExpanded="False"
Style="{StaticResource CustomExpanderStyle}">
<Grid Margin="20 5 0 5">
<Grid.RowDefinitions>
@ -728,6 +732,7 @@
Drop="LbxExcludedPaths_OnDrop"
ItemTemplate="{StaticResource ListViewTemplateAccessLinks}"
ItemsSource="{Binding Settings.IndexSearchExcludedSubdirectoryPaths}"
Loaded="lbxExcludedPaths_Loaded"
SelectedItem="{Binding SelectedIndexSearchExcludedPath}" />
</Border>

View file

@ -15,7 +15,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
public partial class ExplorerSettings
{
private readonly SettingsViewModel _viewModel;
private readonly List<Expander> _expanders;
private readonly List<Expander> _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<Expander>
{
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<Expander>
{
GeneralSettingsExpander,
ContextMenuExpander,
PreviewPanelExpander,
EverythingExpander,
ActionKeywordsExpander,
QuickAccessExpander,
ExcludedPathsExpander
};
_expanders.AddRange(expanders);
}
}
}