Reputation: 3034
My application date is required , if i double click date in calender control , getting null Date , i want disable double click how to do that ? below i added my code
<CalendarDatePicker
Name="calendarPicker"
Width="250"
Margin="30,10,10,10"
Date="{Binding Date, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
MaxDate="{Binding MaxDateTime}"/>
Upvotes: 0
Views: 492
Reputation: 483
I couldn't find a way to accomplish this via a property, but you can accomplish this by adding an event handler on the DateChanged event. You'll want to make sure you have a default value or value assigned to the CalendarDatePicker
to start off or this may cause problems.
<CalendarDatePicker
Name="calendarPicker"
Width="250"
Margin="30,10,10,10"
Date="{Binding Date, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
MaxDate="{Binding MaxDateTime}"
DateChanged="DatePicker_DateChanged"/>
and then adding this in the code behind for the XAML page:
private void DatePicker_DateChanged(CalendarDatePicker sender, CalendarDatePickerDateChangedEventArgs args)
{
if (!sender.Date.HasValue) sender.Date = args.OldDate;
}
Upvotes: 1