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
Curtis,
This was exactly what I was looking for, a programatic way to access the embedded xamMonthCalendar inside the xamDateTimeEditor. However, I am not having success with the samples above.
Using Snoop it seems that the calendar is actually part of a popup in the adorner layer and I cannot find it in the VisualTree of the DateTimeEditor or in the Template by name. Did the structure of the control change?
Thanks for any tips.
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.