目前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的引用。
阅读(11706) | 评论(0) | 转发(0) |