Browse Source

focus DropDown after DropDown popup closed, otherwise focus is unpredicatable

Andrey Kunchev 7 years ago
parent
commit
16ebfb5be9
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/Avalonia.Controls/DropDown.cs

+ 12 - 0
src/Avalonia.Controls/DropDown.cs

@@ -179,10 +179,22 @@ namespace Avalonia.Controls
             if (_popup != null)
             {
                 _popup.Opened -= PopupOpened;
+                _popup.Closed -= PopupClosed;
             }
 
             _popup = e.NameScope.Get<Popup>("PART_Popup");
             _popup.Opened += PopupOpened;
+            _popup.Closed += PopupClosed;
+
+            base.OnTemplateApplied(e);
+        }
+
+        private void PopupClosed(object sender, EventArgs e)
+        {
+            if (Focusable)
+            {
+                Focus();
+            }
         }
 
         private void PopupOpened(object sender, EventArgs e)