Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 忽略Esc处理程序_C#_Wpf - Fatal编程技术网

C# 忽略Esc处理程序

C# 忽略Esc处理程序,c#,wpf,C#,Wpf,按下Esc时不会触发以下代码。有人能给我一些见解吗? 我喜欢更改光标(比如从绘图模式转换为指针模式) 谢谢。@amit的解决方案: public override void OnKeyDown(MyCanvas dc, KeyEventArgs e) { if (e.Key == Key.Escape) { _line = null; dc.CurrentTool = ToolType.Pointer; dc.Cursor = Cu

按下Esc时不会触发以下代码。有人能给我一些见解吗? 我喜欢更改光标(比如从绘图模式转换为指针模式)

谢谢。

@amit的解决方案:

public override void OnKeyDown(MyCanvas dc, KeyEventArgs e)
{
    if (e.Key == Key.Escape)
    {
        _line = null;
        dc.CurrentTool = ToolType.Pointer;
        dc.Cursor = Cursors.Arrow;
        dc.ReleaseMouseCapture();

    }
}

您是否在函数中设置了断点,并在按下任意键时验证是否调用了该断点?谢谢…通过在top(编辑:)@amitkohan中添加代码解决了此问题,而不是更改您的问题,请将您的解决方案放在下面的“答案”部分,并将其标记为已回答。hmmm。我在修改时没有注意到这样的链接/按钮。
public override void OnKeyDown(MyCanvas dc, KeyEventArgs e)
{
    if (e.Key == Key.Escape)
    {
        _line = null;
        dc.CurrentTool = ToolType.Pointer;
        dc.Cursor = Cursors.Arrow;
        dc.ReleaseMouseCapture();

    }
}