tags:

views:

267

answers:

1

How to provide an option to select No dates(None) in datepicker control?

Please help!!

Thanks Sharath

A: 

Now, I have actually installed the WPF Toolkit and tried it...

I found out that if you manually delete the text in the textbox part of the datepicker, then the SelectedDate is actually deleted. Optionally, you can add a button that deletes the SelectedDate directly.

WPF code:

    <my:DatePicker Name="DatePicker1" Height="26"  xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" />
    <Button Name="btnDeleteDate" Height="26"  Width="90">Set no date</Button>

Code behind (VB):

Private Sub btnDeleteDate_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnDeleteDate.Click
    DatePicker1.SelectedDate = Nothing
End Sub

If you want the todays date not to be highlighted as grey, you can set IsTodayHighlighted to false.

It is still the "active date" though, which is a visible box around a date that is kind of a "cursor" that is the start point if you move around with the arrows on the keybord. This is not the same as SelectedDate, but the selected date is set immediately when you start to move it around.

awe
Can you please show the example?
sDev
Sorry, my original answer (*Try to set SelectionMode=None*) does not apply. I was only reading documentation somewhere. It was probably not the same control.. I have added a more complete answer here now.
awe
I found out that the `SelectionMode` is only available on the **Calendar** control, which was described in the same article as the **DatePicker** control: http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-calendar-datepicker-walkthrough.aspx
awe