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
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.
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.
Clarification: Just realized that OnApplyTemplate() is getting called again when the drop down opens. Sorry, I missed that on the first pass. So, after the Template is applied that does contain the "PART_Calendar" item, I can save a reference to it an modify my DisabledDates as needed.
Thanks for the good info.
I'm glad I can help. It sounds like you found your answer. Good luck with your further programming endeavors!
Hi Curtis,
I am using XamDateTimeEditor and applying ValueConstraint as follows
InfraEditor:XamDateTimeEditor.ValueConstraint>
<InfraEditor:ValueConstraint MinInclusive="01/01/1753">
</InfraEditor:ValueConstraint>
</InfraEditor:XamDateTimeEditor.ValueConstraint>
This adds slowness when I access the control while entering date. Is there any way to avoid this slowness or is there any other way to keep ValueConstraint to the control.
Hello Chetan,
If you feel like there is a serious performance issue in this control, please open a developer support case reporting this as a bug. I'm surprised to hear that you see this happening. A sample project demonstrating the slow down would be helpful for us.http://ko.infragistics.com/support/submitrequest.aspx
You could also try putting the constraint into your data source/view model class. Putting logic into the Model or View Model is always a good optimization rather than putting it into the View. The many logic-based features in the VIew are convenient and helpful. However, whenever you need to make the UI as light-weight as possible, sometimes it helps to optimize what is happening in the UI.
Thanks,
Hi Chetan,
It turns out the reason the XamDateTimeEditor was slow was because the ValueConstraint was set with a string. If you set the value with an explicit DateTime object, the delay goes away. This makes sense since an implicit converter is being called which apparently slows down the control.
Instead of the following:
<igEditors:XamDateTimeEditor> <igEditors:XamDateTimeEditor.ValueConstraint> <igEditors:ValueConstraint MinInclusive="01/01/1753"> </igEditors:XamDateTimeEditor.ValueConstraint></igEditors:XamDateTimeEditor>
Use this:
<igEditors:XamDateTimeEditor> <igEditors:XamDateTimeEditor.ValueConstraint> <igEditors:ValueConstraint> <igEditors:ValueConstraint.MinExclusive> <sys:DateTime>01/01/1753</sys:DateTime> </igEditors:ValueConstraint.MinExclusive> </igEditors:ValueConstraint> </igEditors:XamDateTimeEditor.ValueConstraint></igEditors:XamDateTimeEditor>
Thanks!
What about this topic??
OK. This is my xaml, it is very simple.
Is this something you can replicate in a small sample project? If yes, remove binaries from the project, zip it, and add it here and I will determine what is going on and will fix the problem for you.
Thank you,
Hello!!
I'm using the XamMaskEditor and it throws this error "Input does not match the mask" when the editor loses the focus. The only property I'm using is this Mask="{}{date}{time}". When I run the code I set a value like this 12/29/2010_04:10 AM, then the error message appears. Thanks for your help!!