Using XamDateTimeInput, I would like to bind a list of valid dates which can be selected. Any date not in the list binded to the control would be disabled from the user selection.
How can I achieve this?
Hello ,
Thank you for posting. Out control doesn’t support date range selection, may be you can add two dateTimeInput one for start date and another one for end date .
Although to restrict/block selected dates you can refer to this post provided more information with a sample application.
https://ko.infragistics.com/community/forums/f/ultimate-ui-for-wpf/96691/how-to-block-selected-dates-in-xamdatetimeinput
Let me know if you have any question.
Regards,Divya Jain
Thank you but I'm not looking for date range selection. Only to disable/enable dates which are driven by the binded list of available dates.
Any date not within the list would be disabled from selection
example: I have a list of dates 7/1, 7/2, 7/5, 7/8, 7/9when the user clicks XamDateTimeInput, one of the above dates can be selected, but any other date not in the list is disabled.
I'm close to this solution using:
<ig:XamDateTimeInput.ValueConstraint > <ig:ValueConstraint Enumeration="{Binding DateList}" /> </ig:XamDateTimeInput.ValueConstraint>
but this does not disable the non-available dates, instead it popups up a warning saying "Value not found in list of possible choices"
The warning is not desirable, we would like to simply disable those dates avoiding this warning to the user.
This error message is coming through InvalidValueBehavior property. The default value of the xamInputs’ InvalidValueBehavior property is DisplayErrorMessage. You can change it to any other enum value(may be ‘ReverValue’), you can set it like this:
<ig:XamDateTimeInput Grid.Column="1" Value="{Binding Date, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" SpinIncrement="1d" Height="35" InvalidValueBehavior="RevertValue"> <ig:XamDateTimeInput.ValueConstraint> <ig:ValueConstraint Enumeration="{Binding DateList}" /> </ig:XamDateTimeInput.ValueConstraint> </ig:XamDateTimeInput>
or another option to restrict the calendar dates are to set DisabledDates of the XamCalendar of the XamDateTimeInput’s containing a particular range. I attached a sample here for your reference.
Regards,
Divya
0640.WpfApplication1.zip