询问者
用反射方法加载WPF窗体后不相应方向键

问题
-
主窗体是Form的,然后在主窗体上用反射的方法加载了一个WPF窗体。下面是反射的方法。
string filePath = Environment.CurrentDirectory + @"\WPFDll.dll"; System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(filePath); foreach (Type type in asm.GetTypes()) { if (type.IsClass && type.IsPublic && type.GetInterface(typeof(IWindowsFramework).FullName) != null) { WPFWindow = (IWindowsFramework)asm.CreateInstance(type.FullName); } }
其中IWindowsFramework是自定义的接口,包含一个ShowWindow方法。在WPF的Dll里如下面的方式实现了这个方法。
#region IWindowsFramework Members public void ShowWindow() { Window1 windowsInterface = new Window1(); windowsInterface.Show(); } #endregion
然后在主窗体Form里调用这个方法让WPF窗体显示出来,结果显示出来的WPF窗体在KeyDown中不相应方向键,Enter键,Tab键。其它按键可以正确响应。不知道是什么原因。更奇怪的是KeyUp可以响应所有的按键。
请各位帮帮忙。我有小例子程序。