protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Space)
{
// Alt+Space should bring up system menu, we shouldn't handle it.
if ((Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.Alt)
{
if (e.OriginalSource == this)
{
IsPressed = true;
e.Handled = true;
}
}
}
else if (e.Key == Key.Enter)
{
if (e.OriginalSource == this)
{
if (IsHighlighted)
{
SetSelectedOnInput();
e.Handled = true;
}
}
}
base.OnKeyDown(e);
}