wpf项目使用winform控件

环境:Win10、VS2017

一、新建WPF项目

 

 

2. WPF项目添加System.Windows.Forms和WindowsFormsIntegration引用

 

 

3.  编写WPF窗体代码

3.1. 头部添加引用

1 xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
2 xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"

 

3.2. 内容引用WinForm控件

1 <wfi:WindowsFormsHost  Width="180" Height="20">
2   <wf:DateTimePicker Format="Custom" CustomFormat="yyyy/MM/dd HH:mm:ss"></wf:DateTimePicker>
3 </wfi:WindowsFormsHost>

 

4. 运行查看效果

 

posted @ 2024-11-11 16:55  陈金灿  阅读(454)  评论(0)    收藏  举报