Wpf WindowsFormsHost导致System.Windows.Forms.Button.Click事件不触发
我正在将windows窗体应用程序转换为WPF,并在转换的第一部分重新使用一些winform控件 要托管winform控件,我使用的是WindowsFormsHost,似乎发生的情况是enter键没有导致按钮。单击winforms按钮上要触发的事件(但是,使用鼠标和空格键单击仍然有效) 您可以通过执行以下操作来复制此行为:Wpf WindowsFormsHost导致System.Windows.Forms.Button.Click事件不触发,wpf,button,windowsformshost,Wpf,Button,Windowsformshost,我正在将windows窗体应用程序转换为WPF,并在转换的第一部分重新使用一些winform控件 要托管winform控件,我使用的是WindowsFormsHost,似乎发生的情况是enter键没有导致按钮。单击winforms按钮上要触发的事件(但是,使用鼠标和空格键单击仍然有效) 您可以通过执行以下操作来复制此行为: <Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WindowsFormsHost>
<wf:Button Text="Hello" Click="Button_Click_1" />
</WindowsFormsHost>
</Grid>
我正在考虑向WindowsFormsHost call按钮添加一个事件处理程序。如果按下enter键且某个按钮处于焦点状态,则执行单击,但我觉得一定有什么我忽略了的,为什么enter键不会导致按钮单击