Search code examples
c#windows-phone-7windows-phone-8windows-phone-8.1

How to only allow '0's and '1's to be put into a textbox in windows phone


In my windows app there is a textfield to input numbers(binary 1 or 0) for users. I'm building this app to convert binary numbers into decimal. Now What I want is , when user enter a binary number in textfield, other numbers should disable, or should give an error message. help me with this. thanx.!!!!


Solution

  • Hook into the KeyUp event of the TextBox and check if the key is 0 or 1. If not, simply delete it.