Hi,
We are using a XamCurrencyEditor which has the following properties set:
PromptChar = ' '; FormatProvider = new CultureInfo("en-US"); Mask = "{double:-12.0}";
We are also overriding the OnKeyUp:
protected override void OnKeyUp(KeyEventArgs e) { if (e.Key == Key.K) Text += "000"; else if (e.Key == Key.M) Text += "000000";
base.OnKeyUp(e);
}
The XamCurrencyEditor works as expected when I manually type in the numbers and the negative sign, but when I push the K or M buttons it will break the mask.
For example, if I were to type 1, then hold down M instead of it reaching the max of 100,000,000,000 it will actually go to 1000,000,000,000 (1 + the value in mask). Now it won't let me leave the editor, but obviously I don't want it look like this.
I've tried handling different events but that did not work.
If I remove the "-" from the Mask, everything works fine.
The only ugly way I can get this to work is by parsing out the value in the mask and adding some conditionals for when to add to the Text.
Any ideas on how I can get this working in a cleaner way?
Thanks in advance for looking at my question.
I'm attaching you a sample project which should behave the way you want.
Hope this helps you.
Regards,
Anastas
Is there a way to get max value or allowable character length of the text box?
No problem.
Thanks for choosing the Infragistics Controls.
Yes you are correct, thanks for the help on this solution!
I wasn't able to brake the attached project with the error which you are describing. You shouldn't get this error since before assigning the changed value I check if the value is correct by invoking the ValidateCurrentValue(which consider to value constraints set in XAML) method.
You will get this error if you remove the value constraints for currencyEditor which are set in XAML:
<local:Ala.ValueConstraint>
<igE:ValueConstraint MinExclusive="-1000000000.00" MaxExclusive="1000000000.00"></igE:ValueConstraint>
</local:Ala.ValueConstraint>