Parsing numbers at PreviewTextInput
Posted
by Nitin Chaudhari
on Stack Overflow
See other posts from Stack Overflow
or by Nitin Chaudhari
Published on 2010-06-08T12:31:08Z
Indexed on
2010/06/08
12:42 UTC
Read the original article
Hit count: 230
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.
© Stack Overflow or respective owner