How to Limit the Input of a Textbox of Windows Phone

Some time ago I have written about the keycode glitch. Other than this glitch, sometimes you might need to limit the scope of input to certain set of characters.Changing the inputscope of the keyboard helps alot. But, sometimes you need more specific filters. For example, if you’re expecting an all-numbers input and you use the “TelephoneNumber” keyboard, you’ll still be able to get “.” or other symbols. Another example is if you need to get an email address input which you would prefer to have in small letters.

Anyway, let’s get to the code. The code is simply one line. Lets assume that you have textbox name txtInput. You’ll just have to add the following code in the event handler of “KeyDown” for the txtInput control.

This line limits the input of the textbox to the numbers 0 to 9. You can change the content between the qoutations into any range of acceptable input characters that you need.

I hope this helps.

App: Saudi Calendar

App Link in WP Store

لقد توقفت عن العمل ببرامج ويندوز فون – هذا التطبيق لم يعد متوفرا

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

التقويم السعودي هو تطبيق لنظام ويندوز فون لعرض التقويم الهجري و القيام بالتحويل بين التواريخ الهجرية و الميلادية. يستخدم هذا التطبيق تقويم أم القرى للتحويل وهو التقويم الرسمي في المملكة العربية السعودية.

خصائص التطبيق

الواجهة المبسطة و المتوفرة باللغة العربية و الإنكليزية
إمكانية عرض تأريخ اليوم الهجري على شاشة القفل (إبتداءا من الإصدار الثاني)
خاصية الأيقونات الحية (لايف تايل) بالأحجام الثلاثة (إبتداءا من الإصدار الثاني)
خاصية عرض التقويمين الهجري و الميلادي بشكل متداخل لسهولة العرض
يوفر خاصية تحويل التواريخ الهجري إلى الميلادي و بالعكس
يوفر خاصية اللايف تايل ليقوم بعرض تأريخ اليوم على سطح المكتب
نطاق التحويل يبدأ من يوم الأول من شهر محرم سنة واحد هجرية ويمتد بشكل غير محدود

إمكانية التغيير اليدوي للتأريخ الهجري بزيادة و نقصان يومين.
و المزيد في الإصدارات القادمة إن شاء الله.

ملاحظة: التطبيق يستخدم تقويم أم القرى للسنوات الهجرية 1350-1500 و خارج هذا النطاق يتبنى التطبيق طريقة التحويل المستخدمة في مركز الدراسات الشرقية في جامعة زيورخ بسويسرا.

إذا كانت لديكم أي ملاحظات أو مقترحات، يرجى كتابتها هنا بشكل تعليق و سأقوم بالرد عليها في أقرب فرصة ممكنة.

Saudi Calendar is a Windows Phone application that displays Hijri calendar and performs Hijri-Gregorian date conversion using Hijrical.org online conversion service. This service uses Um-Alqura calendar for calculation which is the official calendar in Saudi Arabia.

The app has the following features:

  • easy it use interface with Arabic and English interface.
  • Ability to manually shift Hijri date ±2 days
  • support of showing todays hijri date on lockscreen.
  • support of all three sizes of live tiles.
  • Mixed calendar showing Hijri and Gregorian dates.
  • provides any-date Hijri-to-Gregorian and Gregorian to Hijri conversion
  • provides a live tile that is automatically updated to show today’s hijri date simply there on your phone’s desktop.
  • the conversion range starts from Muharram 1st, 1 Hijri and has no limit.
  • more features to come in the future.

Note: The app uses Um-Alqura Calendar for the Hijri years 1350-1500. Out of that range a mathematical conversion method used by the center of oriental studies in Zurich University was adopted.



  • v2.1 (July 16th, 2013)
  • Addign the ability to manually shift Hijri dates ±2 days.
  • v2.0 (Mar. 5th, 2013)
  • A completely re-written user interface.
  • The conversions and calendar calculations are done locally now so there is no need for Internet connection.
  • Support for showing today’s hijri date on the lockscreen.
  • Support for all three sizes of live tiles.
  • v1.1 (Jan. 3rd, 2013)
  • minor bug fixes
  • v1.0:  ( Dec 28th, 2012)
  • First Release


Privacy policy: By using versions 1 and 1.1 of this app, you are agreeing to the terms of use and privacy policy of Hijrical.org. Starting from version 2 there are no user data being collected whatsoever. All correspondence between app users and the developer are not to be disclosed to anyone else.

App store link:



The Agony of Dealing with YallaApps

Before the Dev center registeration was open in Oman, I registered through Microsoft Publishing partner called YallaApps (Paying the same 99$/year). That was about a year ago. I published many apps with them and the process in overall was nothing less than agony. Very slow responses, and most of the time wrong responses an I have to repeat what I need many many times.

Anyway, I felt so happy back in August when I knew that the Dev center is opening in the country I live in. YallaApps informed all their subscribers that they need to register for new accounts in the dev center and pay full and then in November Microsoft would refund your subscriptions. They said if you like to keep the rating and reviews (which are many for my apps) you need to file a request on a specific online form. Which I did very early once they announced it. They also said if you don’t need to keep your ratings and reviews, you can send us a request for deleting the apps from our side and you submit them again with your account.

So, after registering and finishing all their requirments, I waited. And waited some more. I wrote to their blog as a comment and the comment is still waiting moderation for about a month now.

I wrote on their facebook page asking about the migration and no reply for about a week.

I wrote to their support email and I received an auto-reply saying that we received your email, and we’ll respond to you within 48 hours. And for over a week now, nothing.

I received an email three days ago from Microsoft Global Publishing Partner Program saying that a refund will be issued for you dev center subscription and they mentioned nothing about the apps migration. I replied to their email asking about an ETA for the mogration of apps and they replied to me saying that the app migration has already been done. We did not receive a request from Yalla to transfer any apps to you account. No further migration is possible now..!!!

I do not know specifically whose mistake is this, but I am very sure it is not mine and I do not want to pay for the mistakes of Microsoft and/or their partners.

So I looked-up YallaApps and their mother company “Prototype Interactive” in Dubai Media City and I called their phone number many times and all I get is voice mail.

Me and all other people stuck with YallaApps would like Microsoft to take action and protect our rights from a bad Microsoft partner. How can you ask for more devs to come in when the ones you already have are jumping out?

* Update 11-Dec-2012: Someone actually answered my 5th or 6th phone call and I re-explained the issue and they said they will look into it and get bak to me TODAY.

* Update 11-Dec-2012: I received an email from YallaApps asking for details and acknowledging that the migration was finished and my apps we not migrated.

* Update 21-Dec-2012: I received and email from Microsoft (replying to my email on Dec. 10th) saying that there will be a second batch of migrations and they do not guarantee that it will be successful nor they can give a time line.

Number System Converter

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


This is a simple app that performs conversion of numbers between different numbering systems; Binary, Octal, Decimal, Hexadecimal, and Binary-Coded Decimal (BCD). Starting from v1.1, the app supports fraction conversion also with accuracy of up to 12 binary digits.
More systems will be supported in the upcoming versions.
If you would like to suggest a feature for the next version or you have found an issue in the app, contact me on info (at) mohammedalani.com
This app supports Windows phone 7.5 and 8.

Winodws Phone store link:



* v1.1: (Expected publishing date: Dec. 12th, 2012)

  • added BCD conversion.
  • added fraction conversion.

* v1.0:

  • published on Dec. 5th, 2012


Earlier this year I published a small library that performs multiple tasks of number system conversion on this post. As some fellow devs were a bit skeptic about the code and demanded to see the source code, I have created an open-source project on Codeplex with the name WP7NUMConvert and included the conversion library in there.

The link to the project is:


If anyone would like to particpate in the project, be my guest.


A Gathering of Small Number Systems Conversions and Operations for WP7

* UPDATE: I have found many bugs and issues with this original code of this library. For an expanded (and working version) you can look at WP7NC.

I know its not too much but I gathered about 16 number-conversion operations and few logical operators in a small DLL for Windows Phone devs who might need it. The functions are:

Converts a decimal number into a binary number in the form of string  (ex: 10 becomes “1010”)

Converts a decimal number into a binary number in the form of an array of ones and zeros.

Converts a binary number in the form of a string into a decimal number.

Converts a binary array into a decimal number.

Converts a hexadecimal number int he form of a string into a decimal number.

Converts decimal number into a hexadecimal number in the form of string.

Converts a hexadecimal number in the form of a string into a binary number, also in the form of string.

Converts a binary number in the form of a string into a hexadecimal number, also in the form of string.

Perform bitwise AND operation between two binary numbers in the form of a string.

Perform bitwise and between two hexadecimal numbers in the form of a string.

Perform bitwise OR operation between two binary numbers in the form of a string.

Perform bitwise OR operation between two hexadecimal numbers in the form of a string.

Perform bitwise XOR operation between two binary numbers in the form of a string.

Perform bitwise XOR operation between two hexadecimal numbers in the form of a string.

Perform bitwise NOT operation to a binary number in the form of a string.

Perform bitwise NOT operation to a hexadecimal number in the form of a string.

* UPDATE 02-12-2012: I have found out many minor mistakes in some of the conversion function. Thus, I have removed the file and re-written the library as an open-source project. More details can be found here.

Here is the download link:

NumberSystem.DLL v1.0 (10 kbytes)


If you have a suggestion to expand this library, please write it down in the comments or tweet it to me, and I’ll try to include it.

How to Handle the User’s Refusal of the License Agreement/Privacy Policy in WP7 Apps

Its a good idea to put the apps privacy policy, or license agreement or whatever you need the user to agree on before using the app, in a separate page and navigate to it in the first run.
There are two scenarios to do this, you either set the privacy policy page as the default and check if the user agreed on it on every run using the IsolatedStorageSetting. If the user did agree, the app navigates to the MainPage. Personally, I do not prefer this way because the privacy page is loaded on every run.
The more feasible scenario is to load the MainPage and during its loading, check if the user have agreed on the policy or not. If not, the app navigates to the policy. Sounds simple, doesnt it? No its not.
What should happen if the user reject the agreement? The app should close itself, right? Sorry, this can not happen in Silverlight apps (its possible in XNA though). There is not single command in Silverlight that gets the app to shutdown.
There is a possible solution to go around this. First of all, we will be using the second scenario where the app’s MainPage is loaded first and after checking the IsolatedStorageSettings, the app navigates to the privacy policy page. If you are not familiar with IsolatedStorageSettings, there is a very simple tutorial that was put together by the good folks at WindowsPhoneGeek.

You can create a setting called “AgreedToPrivacyPolicy” and assign to it a “TRUE” value after the user agrees to it. The main trick here is that on the policy page you should put only one button “I Agree”. Do not put an “I Don’t Agree” button because there is no command to handle it straight forward. To facilitate the use of the IsolatedStorageSettings in the application, identify the settings in the “Partial Public Class MainPage” like this:

In the MainPage_Loaded sub put the code:

Line 6 is very important, and I will explain to you why later on.
After navigating to your privacy policy, the user clicks on I agree and in the button_click sub you add the lines:

If the user wishes to reject the privacy policy, the user will hit the back button. This would navigate the app to the MainPage and the checking that we added earlier will be invoked again, and again this will navigate the user to the privacy policy page, where it should in fact take the user out of the app. This can be easily achieved by adding the following code to the PrivacyPolicy_Loaded sub:

Line 2 here removes the MainPage from the back list such that when the user presses back, the user goes directly out of the app without invoking an exception. This is, in my opinion, the best way to exit and application.
One more thing is the case where the user accepts the agreement and then the app navigates to the MainPage. What happens if the user presses back from there? Will the user be navigated back to the PrivacyPolicy page? The answer is NO. Because we covered that already in line 6 in the first code snippet in this article. We told the MainPage to check if there is a previous page in the Back Stack and if there is, erase it.