more issuesa

This commit is contained in:
TheXamlGuy
2024-07-23 21:13:16 +01:00
parent 82e5982632
commit 2c3de93faa
3 changed files with 47 additions and 11 deletions
+15 -3
View File
@@ -39,7 +39,20 @@ public class ListBoxExtension
}
}
if (sender.DataContext == listBox.SelectedItem)
{
sender.RaiseEvent(new ItemInvokedEventArgs { RoutedEvent = ItemInvokedEvent });
}
void HandleUnloaded(object? _, RoutedEventArgs __)
{
listBox.SelectionChanged -= OnItemInvoked;
listBox.Unloaded -= HandleUnloaded;
}
listBox.SelectionChanged += OnItemInvoked;
listBox.Unloaded += HandleUnloaded;
return true;
}
@@ -48,13 +61,12 @@ public class ListBoxExtension
if (!TrySetupListBox())
{
void OnAttachedToVisualTree(object? _, VisualTreeAttachmentEventArgs __)
void HandleLoaded(object? _, RoutedEventArgs __)
{
sender.AttachedToVisualTree -= OnAttachedToVisualTree;
TrySetupListBox();
}
sender.AttachedToVisualTree += OnAttachedToVisualTree;
sender.Loaded += HandleLoaded;
}
}