diff --git a/Perspex.Controls/INavigablePanel.cs b/Perspex.Controls/INavigablePanel.cs
new file mode 100644
index 0000000000..e35af5e077
--- /dev/null
+++ b/Perspex.Controls/INavigablePanel.cs
@@ -0,0 +1,15 @@
+// -----------------------------------------------------------------------
+//
+// Copyright 2014 MIT Licence. See licence.md for more information.
+//
+// -----------------------------------------------------------------------
+
+namespace Perspex.Controls
+{
+ using Perspex.Input;
+
+ public interface INavigablePanel
+ {
+ Control GetControl(FocusNavigationDirection direction, Control from);
+ }
+}
diff --git a/Perspex.Controls/Perspex.Controls.csproj b/Perspex.Controls/Perspex.Controls.csproj
index 5ba608adf0..3cdd69bbbb 100644
--- a/Perspex.Controls/Perspex.Controls.csproj
+++ b/Perspex.Controls/Perspex.Controls.csproj
@@ -40,6 +40,7 @@
+
diff --git a/Perspex.Controls/Primitives/SelectingItemsControl.cs b/Perspex.Controls/Primitives/SelectingItemsControl.cs
index 63956b179a..ac8a35a6af 100644
--- a/Perspex.Controls/Primitives/SelectingItemsControl.cs
+++ b/Perspex.Controls/Primitives/SelectingItemsControl.cs
@@ -65,33 +65,25 @@ namespace Perspex.Controls.Primitives
protected virtual void MoveSelection(FocusNavigationDirection direction)
{
- if (this.SelectedItem != null)
+ var panel = this.Presenter?.Panel as INavigablePanel;
+ var selected = this.SelectedItem;
+ var container = selected != null ?
+ this.ItemContainerGenerator.GetContainerForItem(selected) :
+ null;
+
+ if (panel != null)
{
- int offset = 0;
+ var next = panel.GetControl(direction, container);
- switch (direction)
+ if (next != null)
{
- case FocusNavigationDirection.Up:
- case FocusNavigationDirection.Left:
- offset = -1;
- break;
- case FocusNavigationDirection.Down:
- case FocusNavigationDirection.Right:
- offset = 1;
- break;
- }
-
- if (offset != 0)
- {
- var currentIndex = GetIndexOfItem(this.SelectedItem);
- var index = currentIndex + offset;
-
- if (index >= 0 && index < this.Items.Cast