Hi
I need some help here to write some XAML code, sorry for my ignorance.
I was able to disable Saturday and Sunday for XamDateTimeEditor control with the style property.
<igEditors:XamDateTimeEditor> <igEditors:XamDateTimeEditor.Resources> <Style TargetType="{x:Type igEditors:XamMonthCalendar}"> <Setter Property="DisabledDaysOfWeek" Value="Saturday, Sunday" /> </Style> </igEditors:XamDateTimeEditor.Resources></igEditors:XamDateTimeEditor>
I am trying achieve similar line with the below code, setting the business rule driven Min and Max date for XamDateTimeEditor control using CalenderDateRange, I am getting error "The Property Setter 'DisabledDates' cannot be set because it does not have an accessible set accessor"
<igEditors:XamDateTimeEditor> <igEditors:XamDateTimeEditor.Resources> <Style TargetType="{x:Type igEditors:XamMonthCalendar}"> <Setter Property="DisabledDates" > <Setter.Value> <igEditors:XamMonthCalendar.DisabledDates> <igEditors:CalendarDateRange Start="01/01/1000" End="04/01/2010" /> <igEditors:CalendarDateRange Start="04/27/2010" End="12/31/4712" /> </igEditors:XamMonthCalendar.DisabledDates> </Setter.Value> </Setter> </Style> </igEditors:XamDateTimeEditor.Resources></igEditors:XamDateTimeEditor>
I believe I got the syntax wrong here, I need some guidence what is the best way to have the dates appear disabled inte calender control comes as part of XamDateTimeEditor. I under stand, I still need to validate for the dates when use key in those dates outside the range specified above.
The DisabledDates collection is a get-only collection property. You cannot set that property in a Setter just as you cannot set the Items collection of an ItemsControl in a setter. The only way to populate that is to set it on the specific instance. One thing you could possibly do is to create your own attached property and have that property populate the DisabledDates. I've attached an example of doing that.
Thanks for the reply, this works.
But any chance future build will incorporate as standard feature. I expect to set the MinDate and MaxDate for XamDateTimeEditor control and only date within this range be available for selection and rest be appear disabled. It is a bonus if it automatically through error if the manually entered date is out of Min and Max date range like "ValueConstraint" setting, hope fully in coming version.
Your example worked perfectly, all I had to do was to replace the version from 10.2 to my licenced version.
Actually setting MinValue and/or MaxValue on the ValueConstraint of the XamDateTimeEditor will actually be used to determine the min/max date of the xamMonthCalendar used by the XDTE. As to whether the DisabledDates will be added in a future version I cannot say. There are lots of things that determine which features get implemented. I would certainly recommend submitting a suggestion as the # of requests has some influence on this.