Parsing numbers at PreviewTextInput
- by Nitin Chaudhari
I have a WPF application in which I have a hook at PreviewTextInput, through that I get the currently entered character and I have the string already entered. Given this I need to write the following function :
bool ShouldAccept(char newChar,string existingText)
existingText can be comma seperated valid numbers(including exponential) and it should just return false when invalid characters are pressed.
My code(if else based) currently has a lot of flaws, I wanted to know if there is any smart way to do it.