110,546
社区成员
发帖
与我相关
我的任务
分享
楼主这个问题解决了没?遇到了同样的需求
<Window x:Class="WpfApp2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="MainWindow" Height="450" Width="800">
<Grid>
<WindowsFormsHost Width="200" Height="42">
<wf:DateTimePicker />
</WindowsFormsHost>
</Grid>
</Window>
需要添加引用:
1、WindowsFormsIntegration
2、System.Windows.Forms
具体细节见:
【演练:在 WPF 中承载 Windows 窗体控件】
https://docs.microsoft.com/zh-cn/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf