I am using a xamDataGrid and there is a ValueConstraint with a fixed value of 30 for MaxInclusive.
I need to add a binding for MaxInclusive so that I can change it a run time but nothing seems to work.
How can I bind to the MaxInclusive property?
<igWPF:Field Name="Zone1Amps" Label ="Zone Current" Width="150"> <igWPF:Field.Settings> <igWPF:FieldSettings> <igWPF:FieldSettings.EditorStyle> <Style TargetType="igWPF:XamNumericEditor"> <Setter Property="IsEnabled" Value="{Binding IsEditEnabled, ElementName=rampGrid}" /> <Setter Property="Format" Value="0.000" /> <Setter Property="ValueType" Value="{x:Type System:Double}" /> <Setter Property="Mask" Value="{}{double:2.3}" /> <Setter Property="ValueConstraint"> <Setter.Value> <igEditors:ValueConstraint Nullable="False" MinInclusive="0" MaxInclusive="30" ValidateAsType="Double"/> </Setter.Value> </Setter> </Style> </igWPF:FieldSettings.EditorStyle> </igWPF:FieldSettings> </igWPF:Field.Settings> </igWPF:Field>
Hello Robert,
Thank you for the post.
You will not able to bind MaxInclusive at run time because that is not in the visual tree. Instead you would have to bind ValueConstraint. You can refer to this post might help you achieve it.
So how would I bind to the ValueConstraint?
Like this embedded code?
I found the article you mention but nothing seems to work including this.
<igWPF:Field Name="Zone1Amps" Label ="Zone Current" Width="150"> <igWPF:Field.Settings> <igWPF:FieldSettings> <igWPF:FieldSettings.EditorStyle> <Style TargetType="igWPF:XamNumericEditor"> <Setter Property="IsEnabled" Value="{Binding IsEditEnabled, ElementName=rampGrid}" /> <Setter Property="Format" Value="0.000" /> <Setter Property="ValueType" Value="{x:Type System:Double}" /> <Setter Property="Mask" Value="{}{double:2.3}" /> <Setter Property="ValueConstraint" Value="{Binding CurrentLimit, ElementName=rampGrid}" /> </Style> </igWPF:FieldSettings.EditorStyle> </igWPF:FieldSettings> </igWPF:Field.Settings> </igWPF:Field> public static readonly DependencyProperty CurrentLimitProperty = DependencyProperty.Register("CurrentLimit", typeof(double), typeof(NexxCustomXamDataGrid), new PropertyMetadata(30.0, OnNumberRspParamChanged)); public double CurrentLimit { get { return (double)GetValue(CurrentLimitProperty); } set { SetValue(CurrentLimitProperty, value); } } private static void OnNumberRspParamChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { NexxCustomXamDataGrid numberRspParam = e.NewValue as NexxCustomXamDataGrid; if (numberRspParam != null) { ValueEditor editor = d as ValueEditor; ValueConstraint constraint = editor.ValueConstraint; if (constraint == null) editor.ValueConstraint = constraint = new ValueConstraint(); constraint.SetValue(ValueConstraint.MaxInclusiveProperty, 15.0/*numberRspParam.MaxValue*/); constraint.SetValue(ValueConstraint.MinInclusiveProperty, 0.0/*numberRspParam.MinValue*/); } }