The KeyCode Glitch in Windows Phone 7

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″. So I wrote a simple line of code to do the required:

This line basically ends the handling of the key that is pressed if it is not a digit.
What came as a shock to me was that when testing the app on the emulator on the computer, I found out that other characters (some symbols) where also showing up in the textbox along with the numbers. Symbols like ( ) $ % where also “pressable” in the text box. After digging for a while, I found out that these symbols had the same key codes as the digits ..!!!
To get a solid ground of this finding, I created a simplified app that simply shows the key code of the key that you are pressing on the virtual keyboard. Yes. Numbers and few symbols have the same key codes. After testing, the numbers and the symbols having the same key codes such as were frustrating; number 2 and @, number 3 and #, and all the others. The capital and small letters also have the same codes.
Apparently, I was not the only one who had this few other developers also had that issue. Since I have not yet received my Windows phone, I was not able to confirm that this is an Emulator glitch or an OS glitch.
If you have an unlocked Windows phone and Visual Studio, and you would like to confirm, or deny, that issue, download the .xap file of the app I did to view the codes of pressed keys and comment back in here. Here is the app download link to the KeyCodeDisplay.xap.

Moving on to the app development, if you are wondering how to go around this in the WP7 app that you are developing, here is one of the solutions. Use an event called KeyUp instead of the KeyDown used earlier, and put this code in it

I know that changing the InputScope can handle the situation with a PhoneNumberInputScope, but still the special characters such as “.” can cause you a problem. Another case is when you need a limited number of characters to be acceptable instead of the whole keyboard. I needed to use a similar method in my app PassworderPro when I had to create a textbox that accepts only capital letters.

Sending Error Reports from Windows Phone 7 Application

Sometimes it impossible to test for ALL possible exceptions. Sometimes you test on a device and it works, and another device gives a certain exception. In most cases, it is useful for the developer to receive error reports from users. This, of course, happens with the user’s will to cooperate by sending an email containing the exception details.

The simple code I put together is in VB (yes I am an antique-collecting dude who just loves VB), prepares an email for the user to be sent to your support email. Sometimes I am really frustrated how almost all WP7 development article give C# codes.

this code goes into “App.xaml.vb” to handle all unhandled exceptions by displaying a messagebox to the user asking him/her to send the details of the error to the developer.

You have to put this as the first line in your App.xaml.vb :

Afterwards, you’re good to go.

App: ArEn Translator

I have stopped developing for Windows Phone – This app is no longer available


ArEn Translator is an application for Windows Phone 7 and 8 that performs translation from and to Arabic, English, French, Italian, and Spanish. The application uses the online translation service provided by Bing. Thus, the application requires a working internet connection to perform properly.

The application is free and and can be downloaded here:


For any suggestions, bug reports, and feature requests, please email me on info (at) mohammedalani.com


v2.0: (Feb. 2013)

  • A completely re-written UI for better response time and smooth usage.
  • Support for French, Italian, and Spanish Languages.
  • Support for auto-detection of input language.


  • Fixing an issue with ads to improve start-up time.


  • Release of the application.


I have stopped developing for Windows Phone – This app is no longer available


PASSWORDER is a simple powerful application for Windows Phone 7 (WP7). This application generates passwords with very high randomness from CAPITAL LETTERS, small letters, numb3rs and symb()!s.

This application comes in two editions, PASSWORDER FREE (Free) and PASSWORDER PRO (paid).

Current version 1.0 1.0
  • Generate password from all capital letters, small letters, numbers, and passwords.
  • User-controlled password length. (4 to 100)
  • Uses 31 symbols used in MS Windows.
  • High Randomness in password generation.
  • Simple (one-tap) copy-to-clipboard feature to facilitate the use of password in browser or other applications.
  • Ad-supported
  • Generate passwords containing capital letters, small letters, numbers, and passwords.
  • Password Vault, to save all your passwords securely in the same easily-accessible place.
  • Integration of the generator and the vault to facilitate easy saving of generated passwords.
  • The user can control the letters, numbers, and symbols that participate in the password generation.
  • User-controlled password length. (4 to 100)
  • High Randomness in password generation.
  • User can eliminate the symbols that does not fit in his/her password requirements.
  • Simple (one-tap) copy-to-clipboard feature to facilitate the use of password in browser or other applications.
  • No Ads.
Next Version Features Waiting for your suggestions.
Price Free (Ad supported) USD 0.99
Links http://www.windowsphone.com/en-US/apps/dc5ab876-c1d5-4099-bf06-4e67914065f0 http://www.windowsphone.com/en-US/apps/1317802f-5110-47e5-be9d-3c8c18c28cb8


If you have any feature suggestions, bugs, anything to say about the apps, please feel free to contact me on info (at) mohammedalani.com

PassworderPro Changelog:

v1.1  Release Date: 10-Feb-2012

* Added the feature of a password vault. The user can save up to 1000 passwords along with descriptions of these passwords. This password vault is protected by a master password.

* Fixed some UI issues.

v1.0 Release Date: 17-Jan-2012

*First Version published.

App: Hijri


 Hijri for Windows Phone and Hijri Converter for Windows 8

* If you like Hijri for Windows phone, you might also like Saudi Calendar app (التقويم السعودي).

Hijri is a simple application that performs conversion between Hijri and Gregorian dates. It provides a simple interface to convert Hijri-to-Gregorian and Gregorian-to-Hijri dates.

Hijri (for Windows Phone):

In v1.1 a nice feature was added to the converter. This feature is a live tile that shows you today’s date in Hijri, and updates automatically.

The v1.0 of this application used the online service provided by IslamicFinder.org because of the high accuracy of the conversion on this site. Anyway, starting from v1.1, I have moved the service to my own private server so that the conversion is much faster now.

Starting from version 2.0, the conversion is being done using the open API conversion service provided by www.HijriCal.org. The conversion methods used by the HijriCal.org API are:

1. Um-Alqura Calendar (the official calendar of Saudi Arabia). This calendar provides conversion for Hijri dates from 1350 to 1500 hijri. The dates before or after that are converted using option 2.

2. The Hijri calculation method used by Center of Oriental Studies in Zurich University.

If you spot any bugs, please send me reports. Also if you have any suggestions for features to include in the next version, please feel free to contact me on   info (at) mohammedalani.com

Important Notes Regarding the live tile:

1. If you want to turn off the periodic automatic updating of the live tile, please do it from inside the applications. Do not turn the task off from the phone “Settings” menu as it would cause a conflict with the application settings.

2. If you turn off the auto-update of live tile, the live tile will be updated when you start the application.

3. In case you don’t see the date on the live tile, just wait for a few seconds, the tile will flip and show you the date on the back.

4. If you do not open the application for 14 days, the live tile will stop being updated. This is WP7 restriction, for all periodic tasks.



v2.0: (Expected Release date 1-1-2013)

* Move the conversion service to Hijrical.org.

v1.1: (Release date 25-2-2012)

* Added a live tile that shows today’s date in Hijri. This tile updates automatically, and you have the choice to enable and disable the automatic updates.

* Some UI improvements:

-Show number-only keyboard when entering day and year.

-Larger font for the month list.

* Change ads to AdMob

* Added checking for network connectivity to prevent irregular application closing.


Initial release of application on 26-01-2012.


Marketplace Link:



Hijri Converter (for Windows 8):

Extra -simple interface with online conversion for highest possible accuracy.



v1.0: (Expected Release date 12-12-2012)

* First app release.


Windows Store Link:

will be available on release.


Privacy Policy:

This application collects anonymous user stats to help improve the service provided. All data collected are anonymous and will be kept securely and not provided to any other entity.

By using this application, you are agree to this privacy policy and to the Terms of Service and Privacy Policy of HijriCal.org as the main conversion service provider.