diff --git a/Perspex.Controls/MenuItem.cs b/Perspex.Controls/MenuItem.cs
index 84aba0f4b5..31cbe4bfe7 100644
--- a/Perspex.Controls/MenuItem.cs
+++ b/Perspex.Controls/MenuItem.cs
@@ -216,15 +216,13 @@ namespace Perspex.Controls
/// The event args.
protected override void OnKeyDown(KeyEventArgs e)
{
- base.OnKeyDown(e);
-
switch (e.Key)
{
case Key.Down:
if (this.IsTopLevel && this.HasSubMenu)
{
- this.IsSubMenuOpen = true;
this.SelectedIndex = 0;
+ this.IsSubMenuOpen = true;
e.Handled = true;
}
@@ -239,6 +237,8 @@ namespace Perspex.Controls
break;
}
+
+ base.OnKeyDown(e);
}
///
@@ -328,6 +328,7 @@ namespace Perspex.Controls
if (popup != null)
{
popup.PopupRootCreated += this.PopupRootCreated;
+ popup.Opened += this.PopupRootOpened;
}
}
@@ -398,5 +399,20 @@ namespace Perspex.Controls
this.Presenter = presenter;
}
}
+
+ private void PopupRootOpened(object sender, EventArgs e)
+ {
+ var selected = this.SelectedItem;
+
+ if (selected != null)
+ {
+ var container = this.ItemContainerGenerator.GetContainerForItem(selected);
+
+ if (container != null)
+ {
+ container.Focus();
+ }
+ }
+ }
}
}
diff --git a/Perspex.Input/FocusManager.cs b/Perspex.Input/FocusManager.cs
index 35703a71ee..9f2a6db517 100644
--- a/Perspex.Input/FocusManager.cs
+++ b/Perspex.Input/FocusManager.cs
@@ -61,7 +61,7 @@ namespace Perspex.Input
{
var scope = control.GetSelfAndVisualAncestors()
.OfType()
- .FirstOrDefault();
+ .FirstOrDefault() ?? this.Scope;
if (scope != null)
{