在WPF中使用WinForm控件

在WPF中使用WinForm控件
在WPF中使用WinForm控件

在WPF中使用WinForm控件方法:

下面以在Wpf中添加ZedGraph(用于创建任意数据的二维线型、条型、饼型图表的一个开源类库)控件,说明在WPF中使用Winform控件的方法。

1、首先添加对如下两个dll文件的引用:WindowsFormsIntegration.dll,

System.Windows.Forms.dll。

2、由于要用到ZedGraph控件,所以也要添加对ZedGraph.dll的引用。

3、在要使用WinForm控件的WPF窗体的XAML文件中添加如下内容(选中部分):

即:

xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"

xmlns:zedgraph="clr-namespace:ZedGraph;assembly=ZedGraph"

4、在WPF的容器控件内如Grid内首先要添加WinForm控件的宿主容器,用于衔接WPF和WinForm,对应XAML如下:

相关主题
相关文档
最新文档