Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.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# 闪烁网和路由命令_C#_Wpf_Command_Scintilla - Fatal编程技术网

C# 闪烁网和路由命令

C# 闪烁网和路由命令,c#,wpf,command,scintilla,C#,Wpf,Command,Scintilla,我在C#WPF应用程序中使用闪烁编辑控件。在我的主窗口中,我设置了一些RoutedCommands。闪烁网控件位于WindowsFormsHost中。闪烁灯控件具有焦点时,路由命令不工作 我尝试捕捉按键并手动执行RoutedCommands,但CanExecute始终失败: WindowsFormsHost wfh = new WindowsFormsHost(); Scintilla editor = new Scintilla(); wfh.Child = editor; wfh.Child

我在C#WPF应用程序中使用闪烁编辑控件。在我的主窗口中,我设置了一些RoutedCommands。闪烁网控件位于WindowsFormsHost中。闪烁灯控件具有焦点时,路由命令不工作

我尝试捕捉按键并手动执行RoutedCommands,但CanExecute始终失败:

WindowsFormsHost wfh = new WindowsFormsHost();
Scintilla editor = new Scintilla();
wfh.Child = editor;
wfh.Child.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(Child_PreviewKeyDown);

....

void Child_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
    if (e.KeyData == Keys.F5)
        // Window1 is the main window class
        // handle is a reference to the main window
        if (Window1.CmdRun.CanExecute(wfh, handle)) {
            Window1.CmdRun.Execute(wfh, handle);
        }
        else {
            Console.WriteLine("CANT EXECUTE");
        }
    }
}
有谁能告诉我如何正确地做到这一点吗

谢谢