C# 闪烁网和路由命令
我在C#WPF应用程序中使用闪烁编辑控件。在我的主窗口中,我设置了一些RoutedCommands。闪烁网控件位于WindowsFormsHost中。闪烁灯控件具有焦点时,路由命令不工作 我尝试捕捉按键并手动执行RoutedCommands,但CanExecute始终失败: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
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");
}
}
}
有谁能告诉我如何正确地做到这一点吗
谢谢