前言
在wpf中使用winform控件或者winform的自定义控件
一、添加引用
WindowsFormsIntegration.dll
System.Windows.Forms.dll
提示:这两个引用都是在程序集中可以直接找到的
二、在要使用WinForm控件的WPF窗体的XAML文件中添加如下内容:
代码如下(示例)
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
三、在WPF中使用WinForm或自定义控件
xa

本文介绍了如何在WPF应用中使用WinForm控件和自定义控件。首先,需要添加WindowsFormsIntegration和System.Windows.Forms的引用。接着,在XAML文件中添加相应代码。然后,在WPF中实例化WinForm或自定义控件,并通过WindowsFormsHost进行嵌入。最后,针对控件不显示的问题,提出了AllowTransparent属性设置的解决方案。
最低0.47元/天 解锁文章
301

被折叠的 条评论
为什么被折叠?



