在项目中遇到使用WPF做上位机,引用Winform控件,特此做一下总结:
1、在设计界面添加:
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
2、或者在引用在中引用
3、添加宿主容器
<wfi:WindowsFormsHost><wf:Label x:Name="LogAnalysis"/></wfi:WindowsFormsHost>
4、标签中引用控件,使用方法和Winform类似
引用其他winform类库也如此,将dll文件引入后,声明命名空间,使用对应的控件。