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
20
XamDateTimeEditor
posted

Is there a way to enable /disable specific dates on a  XamDateTime editor control. This functionality seems to be available in the XamMonthCalendar control and I am able to do this to achieve disabled dates.

For Each itm In datelist

Dim range As CalendarDateRange = New CalendarDateRange(Convert.ToDateTime(itm.Value))

igCalendar.DisabledDates.Add(range)

Next

Or is there a way I can port this functionality from the XamMonthCalendar to the XamDateTimeEditor

 

Parents
  • 9694
    posted

    Good news! The XamDateTimeEditor contains an embedded instance of the XamMonthCalendar. That means you can access this element in a number of ways and apply any customizations you want to the XamMonthCalendar properties directly.

    Since this control is embedded in the XamDateTimeEditor, you could access the control using the WPF VisualTreeHelper. You could recursively search every child element (and every child within every child) until you find the XamMonthCalendar. This would be the easiest way to find the control and would be safe in case the visual layout ever changes within the control template.

    You could also override the Control Template for the XamDateTimeEditor to access and customize how the XamMonthCalendar is applied to the Popup section of the control.

    Another approch is to access the Template name. The XamMonthClaendar is given a template name: PART_Calendar. To access this name you would derive a control from XamDateTimeEditor and override the OnApplyTemplate method and call Template.GetName("PART_Calendar").

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        XamMonthCalendar calendar =
           
    this.Template.FindName("PART_Calendar") as XamMonthCalendar;
    }

    Once you get access to the control, you can make changes to properties. Be aware, some of the properties will be set by the XamDateTimeEditor when the control is initialized and when the user makes changes.

Reply Children