WPF:如何禁用SystemMenu快捷键'Alt + Space'?

时间:2021-03-13 19:43:25

I have a borderless window and created the chrome but I need to disable the 'Alt+Space' shortcut. Any thoughts?

我有一个无边框窗口并创建了chrome,但我需要禁用'Alt + Space'快捷方式。有什么想法吗?

1 个解决方案

#1


8  

I'm not very good with WPF, but after some messing around, this seems to be on the right track. Just throw it in your Window code-behind:

我对WPF不太满意,但经过一番捣乱后,这似乎走在了正确的轨道上。把它扔进你的Window代码隐藏:

    protected override void OnKeyDown(KeyEventArgs e)
    {
        if (Keyboard.Modifiers == ModifierKeys.Alt && e.SystemKey == Key.Space)
        {
            e.Handled = true;
        }
        else
        {
            base.OnKeyDown(e);
        }
    }

#1


8  

I'm not very good with WPF, but after some messing around, this seems to be on the right track. Just throw it in your Window code-behind:

我对WPF不太满意,但经过一番捣乱后,这似乎走在了正确的轨道上。把它扔进你的Window代码隐藏:

    protected override void OnKeyDown(KeyEventArgs e)
    {
        if (Keyboard.Modifiers == ModifierKeys.Alt && e.SystemKey == Key.Space)
        {
            e.Handled = true;
        }
        else
        {
            base.OnKeyDown(e);
        }
    }