一使用
1
引用
2
xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
3
由于WindowsFormsHost会指定需要用
<wfi:WindowsFormsHost>
<wfi:ElementHost>
<.................>
</wfi:ElementHost>
</wfi:WindowsFormsHost>
包裹,且在最外层包裹
<Grid PreviewMouseDown="Grid_PreviewMouseDown">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<GroupBox Name="editGroupBox" Header="{DynamicResource ConditionOrderEdit_AddTitle}" Margin="5" Padding="0 10 0 0" BorderBrush="Gray" PreviewMouseDown="editGroupBox_PreviewMouseDown">
<wfi:WindowsFormsHost Name="ConditionOrderEditWindowsFormsHost" MouseDown="WindowsFormsHost_MouseDown">
<ElementHost>
<ScrollViewer Name="scrollViewer" Grid.Row="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" PreviewMouseDown="scrollViewer_PreviewMouseDown">
二
WindowsFormsHost鼠标事件响应
1
里面的控件可以响应,若使用Forms的控件注意使用System.Windows.Forms.MouseEventArgs
<wfi:WindowsFormsHost Width="80">
<wf:Button MouseDown="Button_MouseDown"/>
</wfi:WindowsFormsHost>
private void Button_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
int i = 0;
}
2
WindowsFormsHost上无法响应需要使用WinPro
3
使用鼠标事件时需注意顶层是否可以获得鼠标事件
1
引用
2
xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
3
由于WindowsFormsHost会指定需要用
<wfi:WindowsFormsHost>
<wfi:ElementHost>
<.................>
</wfi:ElementHost>
</wfi:WindowsFormsHost>
包裹,且在最外层包裹
<Grid PreviewMouseDown="Grid_PreviewMouseDown">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<GroupBox Name="editGroupBox" Header="{DynamicResource ConditionOrderEdit_AddTitle}" Margin="5" Padding="0 10 0 0" BorderBrush="Gray" PreviewMouseDown="editGroupBox_PreviewMouseDown">
<wfi:WindowsFormsHost Name="ConditionOrderEditWindowsFormsHost" MouseDown="WindowsFormsHost_MouseDown">
<ElementHost>
<ScrollViewer Name="scrollViewer" Grid.Row="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" PreviewMouseDown="scrollViewer_PreviewMouseDown">
二
WindowsFormsHost鼠标事件响应
1
里面的控件可以响应,若使用Forms的控件注意使用System.Windows.Forms.MouseEventArgs
<wfi:WindowsFormsHost Width="80">
<wf:Button MouseDown="Button_MouseDown"/>
</wfi:WindowsFormsHost>
private void Button_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
int i = 0;
}
2
WindowsFormsHost上无法响应需要使用WinPro
3
使用鼠标事件时需注意顶层是否可以获得鼠标事件