I’m trying to implement a numeric textbox, but I’m having some issues.
I’ve successfully implemented a method to activate on ValueChanged which separates out the new text and then figures out wether it contains any illegal characters.
The problem is when I’m trying to change the TextInput.Value to the legal string:
textInputA.SetValue(legalText, textInputA);
It crashes the program with an error saying:
System.ArgumentOutOfRangeException: Index and Length must refer to a location within the string.
Parameter name: Length
Whenever the legalText.Length != textInputA.Value.Length
The reason for why I want to use SetValue is that I can then filter out any ValueChanged events caused by the code changing the value, from any events caused by the user typing.
User typing:
args.Origin = null
textInputA.SetValue(legalText, textInputA):
args.Origin != null
So then it’s only a matter of a simple if test:
if (args.Origin == null)