目前WPF还没有DateTimePicker控件,不过,可以通过WPF自带的WindowsFormsHost 控件来调用WINFORM下的时间控件来实现。具体代码示例如下:
点击(此处)折叠或打开
my:WindowsFormsHost Height="20" HorizontalAlignment="Left" Name="windowsFormsHost1" Width="180" xmlns:my="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration">
Forms:DateTimePicker Width="160" Height="20" Format="Custom" ShowUpDown="True" CustomFormat="HH:mm:ss" x:Name="dateTimerFrom" xmlns:Forms ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" />
/my:WindowsFormsHost>
使用时需要添加WindowsFormsIntegration和System.Windows.Forms的引用。