WPF调用Winfrom控件
1.添加2个相关dll引用:WindowsFormsIntegration.dll (负责整合WPF和Windows)、System.Windows.Forms.


2.在 XAML文件中添加两个引用

xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
3.在XAML编码区实现你想添加的控件:

添加的是WINFORM中的DateTimePicker控件
<wfi:WindowsFormsHost>
<wf:DateTimePicker x:Name="dateTimePicker" Width="100"
CustomFormat="yyyy-MM-dd HH:mm:ss "
Format="Custom"></wf:DateTimePicker>
</wfi:WindowsFormsHost>
4.运行界面


浙公网安备 33010602011771号