Hi,
could u tell me, how to disable the date which is less than current date(Today) in a xamdatetimeeditor.
my xaml code is like this.
<iw:XamDateTimeEditor Width="auto" VerticalContentAlignment="Bottom" MinWidth="100" x:Name="xmcDate" DropDownButtonDisplayMode="Always" IsAlwaysInEditMode="True" Grid.Column="1" DisplayMode="IncludeBoth" Initialized="XmcDateInitialized" />
and also i need to do validation here for checking the date is less than current day or not, in case if the user enter the date manually, so will u tell me the event handler name through which i can handle it, if possible tell me with a sample...
Hello,
Did you try to set ValueConstraint?
For example you can add value constraint in xaml
<igEditors:ValueConstraint MinValue={x:Static sys:DateTime.Now}>
Regards,
Anastas
How do I do this in code.
I do not know the dates I need to disable, I will know at runtime, I need to dynamically disable multiple dates at runtime, how do I do this
Unfortunately the xamDateTime editor does not support such functionality.
But the dropDown that actually is xamMonthCalendar supports this. So one solution is to add this code snippet in dropDownOpened event:
XamMonthCalendar dropDownCalendar = Infragistics.Windows.Utilities.GetTemplateChild<XamMonthCalendar>(this.xamDateTime);
Infragistics.Windows.Editors.CalendarDateRange disabledDates = new Infragistics.Windows.Editors.CalendarDateRange(xamDateTime.ComputedMinDate, DateTime.Now);
dropDownCalendar.DisabledDates.Add(disabledDates);
This will disable dates from first date to today.
If you want to disable for example three specific dates, you can add three different CalendarDateRanges.
Hope this helps.
I get the error below.
error: internal WPF code tried to reactivate a BindingExpression that was already marked as detached
I am using - Infragistics3.Wpf.Editors.v9.2 (version 9.2.20092.1007)
Actually I don't know why this BindingExpression is the problem.
But I also have problems with same code with 9.2 version.
So I change the existing code with this:
Popup popup = (Popup)Infragistics.Windows.Utilities.GetDescendantFromName(this.xamDateTime, "PART_Popup");
System.Collections.IEnumerable items = LogicalTreeHelper.GetChildren(popup);
DependencyObject d = items.Cast<DependencyObject>().ToList<DependencyObject>().ElementAt(0);
System.Collections.IEnumerable items1 = LogicalTreeHelper.GetChildren(d);
DependencyObject d1 = items1.Cast<DependencyObject>().ToList<DependencyObject>().ElementAt(0);
XamMonthCalendar xamCalendar = (XamMonthCalendar)LogicalTreeHelper.GetChildren(d1).Cast<DependencyObject>().ToList<DependencyObject>().ElementAt(0);
Infragistics.Windows.Editors.CalendarDateRange disabledDates1 = new Infragistics.Windows.Editors.CalendarDateRange(new DateTime(2011, 3, 18), new DateTime(2011, 3, 21));
xamCalendar.DisabledDates.Add(disabledDates);
xamCalendar.DisabledDates.Add(disabledDates1);
And it works the same way.
Thaks,
i try to use the below code in my xaml, but MinValue is not present inside the value constraint of a xamdatetimeeditor, so could you tell me how to do it...
<iw:ValueConstraint MinValue={x:Static sys:DateTime.Now}>
and am using the xamdatetimeeditor in my application and i want to do validation to check weather the date enterred or selected by the user is less than current date or not, so could you tell me is there any event handler like Textleave or something is there in xamdatetime editor to do the validation..
Because i tried with lostfocus and textchanged event handler, but it is giving exception in some cases like textchanged event is giving exception if the user try to enter the date manually by typing it and lostfocus will execute the same report twice...
Actually the properties of ValueConstraint are MinInclusive and MinExclusive.
So your code should look like:
<igEditor:XamDateTimeEditor >
<igEditor:XamDateTimeEditor.ValueConstraint>
<igEditor:ValueConstraint MinInclusive="{x:Static sys:DateTime.Now}" />
</igEditor:XamDateTimeEditor.ValueConstraint>
</igEditor:XamDateTimeEditor>
Thanks,