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.运行界面



posted @ 2012-02-13 10:29  飞蛾扑火  阅读(590)  评论(1编辑  收藏  举报