From 39ce111017d05f4f9ef5b8aeaea01b4d42d3a314 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 6 Jun 2021 15:22:45 +0300 Subject: Fixed rare issue with SearchComboBox. Related Work Items: #5355 --- .../Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/Tango.SharedUI') diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs index 011087d54..010175e0c 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs @@ -219,6 +219,10 @@ namespace Tango.SharedUI.Controls { e.Handled = true; + var presentationSource = PresentationSource.FromVisual(_listBox); + + if (_listBox == null || System.Windows.Input.Keyboard.PrimaryDevice == null || presentationSource == null) return; + if (!_listBox.IsFocused) { FocusList(); @@ -229,13 +233,13 @@ namespace Tango.SharedUI.Controls _listBox.RaiseEvent( new KeyEventArgs( System.Windows.Input.Keyboard.PrimaryDevice, - PresentationSource.FromVisual(_listBox), 0, Key.Up) + presentationSource, 0, Key.Up) { RoutedEvent = System.Windows.Input.Keyboard.KeyDownEvent }); _listBox.RaiseEvent( new KeyEventArgs( System.Windows.Input.Keyboard.PrimaryDevice, - PresentationSource.FromVisual(_listBox), 0, Key.Up) + presentationSource, 0, Key.Up) { RoutedEvent = System.Windows.Input.Keyboard.KeyUpEvent }); } else @@ -243,13 +247,13 @@ namespace Tango.SharedUI.Controls _listBox.RaiseEvent( new KeyEventArgs( System.Windows.Input.Keyboard.PrimaryDevice, - PresentationSource.FromVisual(_listBox), 0, Key.Down) + presentationSource, 0, Key.Down) { RoutedEvent = System.Windows.Input.Keyboard.KeyDownEvent }); _listBox.RaiseEvent( new KeyEventArgs( System.Windows.Input.Keyboard.PrimaryDevice, - PresentationSource.FromVisual(_listBox), 0, Key.Down) + presentationSource, 0, Key.Down) { RoutedEvent = System.Windows.Input.Keyboard.KeyUpEvent }); } //base.OnPreviewMouseWheel(e); -- cgit v1.3.1