From 2f4887318495bfbf1fffa772bf65e729a678eceb Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 19 Oct 2017 00:26:27 +0200 Subject: [PATCH] Select dropdown item on focus. Arrow keys within the dropdown are handled by the keyboard navigation handler, so detect when this focuses a new item and select it. --- src/Avalonia.Controls/DropDown.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Avalonia.Controls/DropDown.cs b/src/Avalonia.Controls/DropDown.cs index cdb179cac9..6b27c479ba 100644 --- a/src/Avalonia.Controls/DropDown.cs +++ b/src/Avalonia.Controls/DropDown.cs @@ -96,6 +96,16 @@ namespace Avalonia.Controls this.UpdateSelectionBoxItem(this.SelectedItem); } + protected override void OnGotFocus(GotFocusEventArgs e) + { + base.OnGotFocus(e); + + if (!e.Handled && e.NavigationMethod == NavigationMethod.Directional) + { + e.Handled = UpdateSelectionFromEventSource(e.Source); + } + } + /// protected override void OnKeyDown(KeyEventArgs e) {