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
210
XamDateTimeInput block dates
posted

I have a XamDataGrid where I use the XamDateTimeInput as EditTemplate for a TemplateField.
I don't use the default DateTimeField, because I think the Calendar of it is pretty ugly and wasn't able to change the it's Template to the one of the XamDateTimeInput.

I now have the problem, that I have a List of Dates that only shall be selectable, and have gaps between them. For example 14.08.2018 till 16.08.2018, 21.08.2018 and so on. Because of that MaxValue and MnValue aren't enough.
I have tried to use the ValueConstraint Enumeration, what threws an exception at the confirmation of the Value but I can still select the Date in the Calendar and so on.

                        <igDP:TemplateField.EditTemplate>
                            <DataTemplate>
                                <ig:XamDateTimeInput
                                    Value="{igEditors:TemplateEditorValueBinding}"
                                    >
                                    <ig:XamDateTimeInput.ValueConstraint>
                                        <ig:ValueConstraint Enumeration="{Binding Source={StaticResource enum}, Path=MyEnum}"/>
                                    </ig:XamDateTimeInput.ValueConstraint>
                                </ig:XamDateTimeInput>
                            </DataTemplate>
                        </igDP:TemplateField.EditTemplate>

Back with the XamDateTimeEditor I had the same problem, I tried to solve with the following code. But the loop takes extremely long.

private void XamDateTimeEditor_DropDownOpened(object sender, RoutedEventArgs e)
        {

            XamMonthCalendar xamMonthCalendar = Infragistics.Windows.Utilities.GetTemplateChild<XamMonthCalendar>((XamDateTimeEditor)sender);

            xamMonthCalendar.DisabledDaysOfWeek = Infragistics.Controls.DayOfWeekFlags.Sunday;
            xamMonthCalendar.MinDate = DateTime.Today;

            DataTable dt = Daten.GibNotAllowedDates(GlobaleVariablen.selGruppe);



            foreach (DataRow dr in dt.Rows)
            {
                Infragistics.Windows.Editors.CalendarDateRange calendarDateRange = new Infragistics.Windows.Editors.CalendarDateRange((DateTime)dr["Datum"]);
                xamMonthCalendar.DisabledDates.Add(calendarDateRange);

            }

        }

Parents
  • 33390
    Verified Answer
    Offline posted

    Hello Benedikt,

    I have been investigating into the behavior you are referring to, and I have reproduced it. I am able to see the behavior in which an error message appears after selecting a date that does not exist in the Enumeration for the ValueConstraint, but it is still possible to commit that value when using a TemplateField. This appears to happen when using either a XamDateTimeInput or a XamDateTimeEditor within a TemplateField, but it does not happen if you use a DateTimeField with an EditorStyle for the XamDateTimeEditor that sets the constraint that way. That may be a possible workaround for you in this case, but it would require usage of the XamDateTimeEditor, which you had mentioned you don’t really want to do.

    For the XamDateTimeInput, the workarounds that I can recommend are to write a Style for CalendarDay and either bind the IsEnabled property with a converter to your Enumerations collection, or handle the PreviewMouseDown event using an EventSetter and check the CalendarDay.StartDate. In the converter, you can return false for the IsEnabled property if the StartDate does not exist in your Enumeration collection, and you can mark the PreviewMouseDown event handled if you decide to go that route.

    I am attaching a sample project to demonstrate the IsEnabled property-binding route. I hope this helps.

    This behavior is unexpected, and as such, I have asked our engineering staff to examine it further. To ensure it receives attention, I have logged this behavior in our internal tracking systems with a development ID of 256430. I have also created a private support case with an ID of CAS-197450-H6S5L4 for you that I will link to this issue so that you can be notified of when a fix or other resolution becomes available. You can access this support case here.

    Please let me know if you have any other questions or concerns on this matter.

    XDGDateTimeInputConstraint.zip

Reply Children
No Data