5.0.9 C# wpf通过WindowsFormsHost嵌入winform控件
本文介绍了如何在WPF应用中嵌入WinForm控件,即WindowsFormsHost的使用方法。
一、两种方法添加window控件到wpf中。
方法1:使用代码添加控件到WindowsFormsHost中。
<WindowsFormsHost Name="wfhHost" Width="200" Height="100" >
</WindowsFormsHost>
var button = new System.Windows.Forms.Button();
button.Name = "window button";
button.Text = "window button";
button.Click += Button_Click1;
button.Width = 100;
button.Height = 50;
wfhHost.Child = button;
方法