2012-05-18 33 views
11

根據this post,在.net 4中有一個單獨的DatePicker控件。我試過了,我沒有看到讓它選擇一天的時間的好方法。用於WPF 4.0的DateTimePicker

是否有一種簡單的方法通過編輯XAML模板將DatePicker轉換爲DateTimePicker?如果不是,獲取WPF 4.0的DateTimePicker的最佳方式是什麼?

回答

8

沒有一個人沒有自己製作或使用第三方控件。然而,有一個的WinForms內,如果你想速戰速決,不支持數據綁定...

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

<window:WindowsFormsHost > 
    <wf:DateTimePicker Format="Time" ></wf:DateTimePicker> 
</window:WindowsFormsHost> 

只是一個時間選擇器,但可以很容易地用一個datepicker配對。您還需要對WindowsFormsIntegration和System.Windows.Forms的引用。