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

WPF调用Winfrom控件

WPF调用Winfrom控件

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

WPF调用Winfrom控件

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

3.在XAML编码区实现你想添加的控件

WPF调用Winfrom控件

添加的是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.运行界面

WPF调用Winfrom控件



相关文章:

  • 2021-12-13
  • 2022-12-23
  • 2021-11-04
  • 2021-05-13
  • 2021-12-26
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
相关资源
相似解决方案