WindowsPhoneGeek

WPAppInfo

Login | Join (Why?)

rss rss rss
logo

The KeyCode Glitch in Windows Phone 7

2/3/2012

source: mohammedalani.com

Mobile application development is a very new field for me. Being a university professor has got me through some VB courses that were not so deep, but I might not call myself a professional developer. Anyway, few weeks ago I had an increasing interest in mobile application development and I decided to start with WP7 development because I had some experience in the VB environment.

I installed the Visual Studio 2010 Express for Windows Phone. I started having some trouble when I needed to get a TextBox (which is a simple text entry space) to receive only numbers from the user and not allow the user to enter anything but numbers.

A simple solution would be the use of an event called KeyDown that is triggered whenever a key is pressed. Afterwards, I need to filter the pressed key such that if it is a number, it would pass, and any other key would be ignored. The easiest way to do this is through the key codes from 48 to 57 which are the correspondent codes to the keys "0?, "1?, "2?,.."9?.

...Read more

You can also follow us on Twitter @winphonegeek

Comments

Add comment to 'The KeyCode Glitch in Windows Phone 7'

Comment

New! WindowsPhoneGeek Component Marketplace

Our Top Articles & Free books

Our Top Tips & Samples