Skip to content

Commit 13917d1

Browse files
authored
Merge pull request #754 from Flow-Launcher/fix_converter_casting_null
Dev branch: fix issue with converters casting to null values
2 parents aeb9b96 + 9e31c77 commit 13917d1

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

Flow.Launcher/Converters/OpenResultHotkeyVisibilityConverter.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ public class OpenResultHotkeyVisibilityConverter : IValueConverter
1616
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1717
{
1818
var hotkeyNumber = int.MaxValue;
19-
20-
if (value is ListBoxItem listBoxItem)
21-
{
22-
ListBox listBox = ItemsControl.ItemsControlFromItemContainer(listBoxItem) as ListBox;
19+
20+
if (value is ListBoxItem listBoxItem
21+
&& ItemsControl.ItemsControlFromItemContainer(listBoxItem) is ListBox listBox)
2322
hotkeyNumber = listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1;
24-
}
2523

2624
return hotkeyNumber <= MaxVisibleHotkeys ? Visibility.Visible : Visibility.Collapsed;
2725
}

Flow.Launcher/Converters/OrdinalConverter.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ public class OrdinalConverter : IValueConverter
88
{
99
public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
1010
{
11-
if (value is ListBoxItem listBoxItem)
12-
{
13-
ListBox listBox = ItemsControl.ItemsControlFromItemContainer(listBoxItem) as ListBox;
11+
if (value is ListBoxItem listBoxItem
12+
&& ItemsControl.ItemsControlFromItemContainer(listBoxItem) is ListBox listBox)
1413
return listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem) + 1;
15-
}
1614

1715
return 0;
1816
}

0 commit comments

Comments
 (0)