diff --git a/Flow.Launcher/Converters/OpenResultHotkeyVisibilityConverter.cs b/Flow.Launcher/Converters/OpenResultHotkeyVisibilityConverter.cs index 7ab13190a..b031dc41c 100644 --- a/Flow.Launcher/Converters/OpenResultHotkeyVisibilityConverter.cs +++ b/Flow.Launcher/Converters/OpenResultHotkeyVisibilityConverter.cs @@ -17,7 +17,17 @@ public class OpenResultHotkeyVisibilityConverter : IValueConverter if (value is ListBoxItem listBoxItem && ItemsControl.ItemsControlFromItemContainer(listBoxItem) is ListBox listBox) - number = listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1; + { + var dataItem = listBoxItem.DataContext; + if (dataItem != null) + { + var index = listBox.Items.IndexOf(dataItem); + if (index >= 0) + { + number = index + 1; + } + } + } return number <= MaxVisibleHotkeys ? Visibility.Visible : Visibility.Collapsed; } diff --git a/Flow.Launcher/Converters/OrdinalConverter.cs b/Flow.Launcher/Converters/OrdinalConverter.cs index 9aed2e07b..c07f46a1c 100644 --- a/Flow.Launcher/Converters/OrdinalConverter.cs +++ b/Flow.Launcher/Converters/OrdinalConverter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Globalization; using System.Windows.Controls; using System.Windows.Data; @@ -15,9 +15,20 @@ public class OrdinalConverter : IValueConverter return 0; } - var res = listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1; - return res == 10 ? 0 : res; // 10th item => HOTKEY+0 + var dataItem = listBoxItem.DataContext; + if (dataItem == null) + { + return 0; + } + var index = listBox.Items.IndexOf(dataItem); + if (index < 0) + { + return 0; + } + + var res = index + 1; + return res == 10 ? 0 : res; // 10th item => HOTKEY+0 } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new InvalidOperationException(); diff --git a/Flow.Launcher/ResultListBox.xaml b/Flow.Launcher/ResultListBox.xaml index 825d92d18..e8e5d8d21 100644 --- a/Flow.Launcher/ResultListBox.xaml +++ b/Flow.Launcher/ResultListBox.xaml @@ -82,7 +82,7 @@ - +