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
You can try to use InvalidValueBehavior="RevertValue". If user enters invalid value then after hitting the enter, tab or clicking outside if the editor - the xamNumeric will revert back to the last correct value. Another way to handle this is to hook up to the EditModeEnding/ed, which are fired with the same actions from above(hitting the enter, tab or clicking outside if the editor).
But I think it's not possible only the 'Enter' key to force the verification. Removing the focus also will force the validation.
The behaviour "RevertValue" is already set. So I can't see any differents with InvalidValueBehavior="RevertValue".
"EditModeEnding" goes in the right direction, because after I hit the enter key the handler will called.
But I still have the problem that the validation starts immediately after I have changed a character.
Example: The current value is 850 and the minimum value is 300.I would like to set the value 550. Now I delete the "8" = 50. Then the validation starts and changes the value to 300. Hence I'm not able to set the value 550 :(
Is there a property like "StartsVaildation=HitEnter,LostFocus"?
You are using UpdateSourceTrigger="PropertyChanged", which occurs when value of editors/textboxes is changed(like in your case - deleted the "8").
So I think you should changed it to "Explicit", and in the KeyDown event of textbox to invoke the BindingExpression.ValidateWithoutUpdate. You can also use "LostFocus", then the validation will occur when remove the focus.
See the attached project - the textbox(x:Name="ValueTextBox") is updated to validate on pressing the Enter or Tab keys.
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?
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').
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.