From 8f46c1360df227c2339393661088238c9eb76ae7 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 27 Apr 2015 23:03:28 +0200 Subject: [PATCH] Make focus follow listbox selection. --- .../Primitives/SelectingItemsControl.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Perspex.Controls/Primitives/SelectingItemsControl.cs b/Perspex.Controls/Primitives/SelectingItemsControl.cs index ac8a35a6af..30c899d626 100644 --- a/Perspex.Controls/Primitives/SelectingItemsControl.cs +++ b/Perspex.Controls/Primitives/SelectingItemsControl.cs @@ -106,6 +106,18 @@ namespace Perspex.Controls.Primitives break; } + var selected = this.SelectedItem; + + if (selected != null) + { + var container = this.ItemContainerGenerator.GetContainerForItem(selected); + + if (container != null) + { + FocusManager.Instance.Focus(container, true); + } + } + e.Handled = true; } @@ -124,6 +136,7 @@ namespace Perspex.Controls.Primitives if (item != null) { this.SelectedItem = item; + FocusManager.Instance.Focus(selectable); } }