Hello,
I'm not able to find the solution of this. I would like to have a XamNumericEditor where the data type is double and the minimum/maximum can be set.
I use NetAdvantage WPF 2012.2. The documentation say there are Minimum and Maximum properties (http://help.infragistics.com/Help/NetAdvantage/Silverlight/2012.1/CLR4.0/html/InfragisticsSL5.Controls.Editors.v12.1~Infragistics.Controls.Editors.XamNumericEditor_members.html). But with "2012.2" there aren't such kind of properties.
So I tried to set it with "Mask" (http://help.infragistics.com/Help/NetAdvantage/WPF/2011.1/CLR4.0/html/xamEditors_Masks.html) in this way:
<igWPF:XamNumericEditor x:Name="MyEditor" Grid.Row="1" Grid.Column="2" Width="80" SpinButtonDisplayMode="Always" Theme="IGTheme" Value="0" Mask="{}{double:4.1}{number:0-255}">
But this doesn't work.
The requirements are as follow:
- The data type should be double and min/max are set to the XamNumericEditor.
- If the user sets a higher value than the maximum, XamNumericEditor should clip the value to the maximum.
- If the user sets a lower value than the minimum, XamNumericEditor should clip the value to the minimum.
- The validation process should start after the user clicks the enter key.
Please have a look at the attached project, where I tried to implement these requirements into the "X Axis Display Maximum and Minimum". You can try it be setting the Maximum x Display value to 9999. The value should be clipped to 850.
Who can help me in this case?
Regards,
Thomas
Hi,
The doubleUpDown from WPF Toolkit (http://wpftoolkit.codeplex.com/wikipage?title=DecimalUpDown&referringTitle=NumericUpDown-derived%20controls) is nearly perfect.Positive:The maximum and minmum can be set.The validation starts after the user hits the enter key.The spin buttons are correctly en-/disabled if the boundary is reached.Negative:The current value won't be clipped if the boundary is reached.
Here is an example how easy doubleUpDown can be used:
<xctk:DoubleUpDown x:Name="XMinDoubleUpdown" Grid.Row="1" Grid.Column="1" FormatString="F1" HorizontalAlignment="Center" Height="25" Width="80" FontSize="14" Value="{Binding ActualMinimumDisplayValue}" Increment="1.0" Maximum="{Binding ActualMaximumDisplayValue}" Minimum="{Binding ActualMinimumValue}" />
@Infragistics: It would be great if you can implement such behaviour in your control.
Greetings,
You can try to use the xamNumeric's ValueConstraints. They can be used like that:
<igWPF:XamNumericEditor.ValueConstraint> <igWPF:ValueConstraint MinInclusive="100" MaxInclusive="850"></igWPF:ValueConstraint> </igWPF:XamNumericEditor.ValueConstraint>
And if a user enters somehow a number outside of this boundary, you can hook up to ValueChanged event. And inside check if the value is correct with IsValueValid property. If it's valid - use the e.NewValue, else - use the e.OldValue, to set xamNumeric's value
Anastas
HI,
Please let me know if you need further assistance regarding this issue.
Sincerely,
Matt
Developer Support Engineer
In order to get rid of the Red box when cleairng out the control add Nullable ValueConstraint - Nullable="false"
MattDeveloper Support Engineer
Hello Anastas,
your attached meets the most requirements, but there are some issues left:
1. The user deletes the whole content a red rectangle will be displayed (This comes from the validation). But I would like to see the last valid value.
2. The user can not type a number higher than the maximum. What I mean is, if I type 999 and hit the enter key, than the value should be clipped to the maximum.This behviour I implemented for the minimum, because it it possible to reach the code in the "xamNum_PreviewKeyDown_1".
I would be nice if you can help me in these two issues.
See the attached project. I hope this time it meets your requirements.
The issue2 from above is because Min and MaxInlcusive properties cannot be bind like you do it in your project. When run it you'll see at the output window such an error: Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=ActualMaximumValue; DataItem=null; target element is 'ValueConstraint'; target property is 'MinInclusive' (type 'Object').
I have attached an example project and video where I explain the difference of DoubleUpDown and NumericEditor.
Video:
1. When you start the application you see that the DoubleUpDown Spin-Buttons have a correct behaviour = They are disabled when the max resp. min values are reached.The spin buttons of NumericEditor are always enabled :(
2. When I enter a value outside the range the DoubleUpDown takes the last valid value. The NumericEditor displays the invalid value :(
3. The up and down key are working for both controls.
4. MouseWheel works only for DoubleUpDown
5. You can enter characters in DoubleUpDown :( => NumericEditor accepts only numbers :)
6. Both controls have the event handler "KeyDown" and both controls reacts only with "tab" not for "enter" :(
Do you have solutions for 1, 2 and 4?