- 7
- 0
- 约4.63千字
- 约 4页
- 2018-02-26 发布于河南
- 举报
在WPF中使用WinForm控件
在WPF中使用WinForm控件方法:
下面以在Wpf中添加ZedGraph(用于创建任意数据的二维线型、条型、饼型图表的一个类库WindowsFormsIntegration.dll,System.Windows.Forms.dll。
由于要用到ZedGraph控件,所以也要添加对ZedGraph.dll的引用。
在要使用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
在WPF的容器控件内如Grid内首先要添加WinForm控件的宿主容器,用于衔接WPF和WinForm,
对应XAML如下:
Grid
wfi:WindowsFormsHost Width=300 HorizontalAlignment=Right
wf:Label x:Name=lblName Text=w
原创力文档

文档评论(0)