欲在WPF中使用Windows Form控制項,我們可以使用WindowsFormsHost控制項來達成此需求。

Step1.放入WindowsFormsHost控制項

[WPF]Using Windows Forms Controls in WPF

放入控制項後可看到如下畫面:

[WPF]Using Windows Forms Controls in WPF

Step2.加入System.Windows.Forms參考

[WPF]Using Windows Forms Controls in WPF

Step3.在XAML文件中加入命名空間

[WPF]Using Windows Forms Controls in WPF

Step4.在XAML文件中加入Windows Forms控制項

[WPF]Using Windows Forms Controls in WPF

[WPF]Using Windows Forms Controls in WPF