Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
435
Disable dates using CalendarDateRange
posted

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.

 

 

 

 

Parents
  • 54937
    Verified Answer
    Offline posted

    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.

    WpfApplication16.zip
Reply Children