Browse Source

Fixed command search text box not focusing after becoming visible for the first time

CPKreuz 3 years ago
parent
commit
d36969b62c
1 changed files with 6 additions and 2 deletions
  1. 6 2
      PixiEditor/Views/UserControls/CommandSearchControl.xaml.cs

+ 6 - 2
PixiEditor/Views/UserControls/CommandSearchControl.xaml.cs

@@ -6,6 +6,7 @@ using System.Windows;
 using System.Windows.Controls;
 using PixiEditor.Models.DataHolders;
 using System.Windows.Input;
+using System.Windows.Threading;
 using PixiEditor.Helpers.Extensions;
 
 namespace PixiEditor.Views.UserControls
@@ -40,8 +41,11 @@ namespace PixiEditor.Views.UserControls
             {
                 if (Visibility == Visibility.Visible)
                 {
-                    textBox.Focus();
-                    Keyboard.Focus(textBox);
+                    Action action = () =>
+                    {
+                        textBox.Focus();
+                    };
+                    Application.Current.MainWindow.Dispatcher.Invoke(DispatcherPriority.Background, action);
                 }
             });