protected override void OnTextInput(TextCompositionEventArgs e) { base.OnTextInput(e); if (e.Handled) { return; } if (e.UserInitiated && e.Text == " " && this.IsMainMenu && (base.CurrentSelection == null || !base.CurrentSelection.IsSubmenuOpen)) { base.IsMenuMode = false; HwndSource hwndSource = PresentationSource.CriticalFromVisual(this) as HwndSource; if (hwndSource != null) { hwndSource.ShowSystemMenu(); e.Handled = true; } } }