wpf怎么调用winform组件
1个回答
展开全部
功能实现主要分三步:
1、添加两个引用:WindowsFormsIntegration.dll(负责整合WPF和Windows)、System.Windows.Forms.
2、在 XAML文件中添加两个引用(粗体部分):
<Window x:Class="CrossBowDemo.MainWindow"
xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Hosting Windows Forms Control In WPF"
Height="300"
Width="650"
ResizeMode="NoResize"
Loaded="WindowLoadedHandler"
>
< /Window>
3、在XAML编码区实现你想添加的控件:
原文添加的是DataGridView控<wfi:WindowsFormsHost>
<wf:DataGridView x:Name="Dg" Dock="Fill" SelectionMode="FullRowSelect">
</wf:DataGridView>
</wfi:WindowsFormsHost>件:
1、添加两个引用:WindowsFormsIntegration.dll(负责整合WPF和Windows)、System.Windows.Forms.
2、在 XAML文件中添加两个引用(粗体部分):
<Window x:Class="CrossBowDemo.MainWindow"
xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Hosting Windows Forms Control In WPF"
Height="300"
Width="650"
ResizeMode="NoResize"
Loaded="WindowLoadedHandler"
>
< /Window>
3、在XAML编码区实现你想添加的控件:
原文添加的是DataGridView控<wfi:WindowsFormsHost>
<wf:DataGridView x:Name="Dg" Dock="Fill" SelectionMode="FullRowSelect">
</wf:DataGridView>
</wfi:WindowsFormsHost>件:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询