I am trying to build a date range control with two XamDateTimeEditors.
I want to use ValueConstraint on each editor to restrict the value of the “From” date based on the user’s input “To” date and vice versa.
In the snippet below, the explicit setting of the MinInclusive on the “From” works as expected, but the Constraints that use binding do not seem to be working. I do not see any binding errors in VS output. Is it possible to use binding on ValueConstraint properties? If not, do I have to handle this in code behind OnEditModeEnding?
Also, I set the ValidateAsType to DateTime, will my explicit setting of MinInclusive fail if the culture does not match how I input the value?
<igEditors:XamDateTimeEditor Grid.Column="2"
x:Name="dtFromDate"
Value="{Binding Path=SelectedFromDate, ElementName=SPSUserControlBase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Text="{Binding Path=SelectedFromDateString, ElementName=SPSUserControlBase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<igEditors:XamDateTimeEditor.ValueConstraint>
<igEditors:ValueConstraint ValidateAsType="DateTime"
MinInclusive="1/1/1753"
MaxInclusive="{Binding Path=Value, ElementName=dtToDate, Mode=OneWay}" />
</igEditors:XamDateTimeEditor.ValueConstraint>
</igEditors:XamDateTimeEditor >
<igEditors:XamDateTimeEditor Value="{Binding Path=SelectedToDate, ElementName=SPSUserControlBase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Text="{Binding Path=SelectedToDateString, ElementName=SPSUserControlBase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="5"
x:Name="dtToDate" >
< igEditors:XamDateTimeEditor.ValueConstraint>
<igEditors:XamDateTimeEditor MinInclusive="{Binding Path=Value, ElementName=dtFromDate, Mode=OneWay}" />
</local: igEditors:XamDateTimeEditor.ValueConstraint>
Hello, I try to set ValueConstraint properties using Bindings, but is seems that they are not working.Setting explicitly the MInInclusiveValue in XAML will work even if the culture doesn’t match to the input value. The value automatically will be converted to supported format.You can handle the appropriate event OnEditModeEnding to set the ValueConstraint In the code and set the ValueConstaint using fallowing example:Style s = new Style(typeof(XamDateTimeEditor)); ValueConstraint vc = new ValueConstraint(); vc.MinInclusive = this.dtFromDate.Value; Setter setter = new Setter(XamDateTimeEditor.ValueConstraintProperty, vc); s.Setters.Add(setter); dtToDate.Style = s; I hope this help.Let me know if that would work in your scenario. Best Regards,DimiDeveloper Support EngineerInfragistics Inc