Building Cross – Platform Mobile Native Apps on Android,iOS, Windows Phone & Windows Store using Single Codebase,PCL with VS 2012/2010 & XAMARIN Tools

Cross Platform App development is always better choice for enterprises where we can avail support for Code Sharing, PCL (Portable Class Libraries) which can shared across multiple platforms of Mobility (aka Android, IOS, Windows Phone 8 / 7.x , Windows Store Apps).

Xamarin introduces such facility where a single code base can be shared across all enterprise mobile platforms along with the benefits of coding on .NET Framework 4.5 / 4.0 & Visual Studio 2012 / 2010.

Lets switch to check to build an Android native app on Visual Studio 2012 with C# for latest SDKs 4.2 using Xamarin tools for Android .

Download Xamarin for iOS, Android , Windows Phone & Windows 8 platforms from here


Lets check the structure of theAndroid App on VS 2012. All layout files can be found under Resources folder. 


  • Next, we are using a single code base file which contains the Business logic & App models that can be shared as a Link with iOS, Windows Phone & Windows Store apps.
  • Lets check the Android 4.2 app built on Visual Studio 2012 & .NET Framework 4.5 platform using Xamarin Tools.





  • Lets check, how to build the same app for Windows Phone 8 or 7.x platform using the same code base along with business logic.
  • Windows Phone 8 project contains the Main.xaml along with the common code base.

string translatedNumber;

private void Translate_Click(object sender, RoutedEventArgs e)

translatedNumber = Core.PhonewordTranslator.ToNumber(PhoneNumberText.Text);

CallButton.Content = “Call ” + translatedNumber;
CallButton.IsEnabled = true;
CallButton.Content = “Call”;
CallButton.IsEnabled = false;

private void Call_Click (object sender, RoutedEventArgs e)
var call = new PhoneCallTask();
call.PhoneNumber = translatedNumber;
call.DisplayName = PhoneNumberText.Text;




  • The Windows Phone App is compatible along with the Windows Phone 8 as well as 7.x versions.
  • For implementing on Windows Store , without altering business logics & models only the views need to be shared.
  • Lets check the project structure of this app for Windows Store.



  • Asynchronous programming is one of core features related to Windows store, windows phone app developments along with other .net app development. Using PCLs, code sharing approaches too we can take help of simple async methods.
  • Shared code for Windows Store App :

string translatedNumber;
public ObservableCollection<PhonewordTranslation> Translations;

private void Translate_Click(object sender, RoutedEventArgs e)
if (!String.IsNullOrEmpty(PhoneNumberText.Text))

translatedNumber = Core.PhonewordTranslator.ToNumber(PhoneNumberText.Text);

CallText.Text = “Call ” + translatedNumber;
// Win8, add to history list
Translations.Add(new PhonewordTranslation() {Phoneword=PhoneNumberText.Text, Phonenumber=translatedNumber });
CallText.Text = “”;

private void ListItems_Click(object sender, ItemClickEventArgs e)
var ci = e.ClickedItem as PhonewordTranslation;
var dialog = new MessageDialog( String.Format (“{0} translates to {1}”, ci.Phoneword, ci.Phonenumber));


  • For IOS development too, the app uses the same shared code -base which targets to iPhone, iPAD & Universal Mac apps which can be built on C#, .NET 4.5 using Visual Studio editor by Xamarin tools for iOS.
  • You can download the entire app over here .

Building Interactive Alarm Clock for Windows Phone

Alarm Clock is an interactive tool for Windows Phone, Windows Surface (Win RT) devices available on marketplace which majorly focus on Alarm settings, Time Settings, execute alarm under locked screen. This article majorly focused on implementing an interactive Alarm Clock for Windows Phone 7.5 & 8 devices having Alarm Clock settings under locked screen, snooze alarm by pressing anywhere on main screen of the app & clock in 24X7 format.


  • The default main screen simply shows up the current time on 12 hour/24 hour basis with seconds time display on enhancement with necessary settings options.


  • Once you click on set alarm option , you would find the alarm time setting option which is based on TimePicker control for Windows Phone.



  • Once time is set, you are good to go & check the Alarm settings on your main screen. The same effects under lock screen too while you can lock the screen from the app itself.

lock screen

  • Next, Check the main settings options for this app which has clock setting on 24X7 basis along with vibrations options during alarm bell ringing. Initially all the settings have to be stored on Isolated Storage.

setting pane

  • The apps background color is changable & you can set your own forefround colors & themes based on phone settings. Alarm Time can be snoozed by pressing anywhere on main screen & displayed under locked screen itself.


  • The Alarm Sound can be changed based on user choice , for this you need write your own class as SoundEffects.cs :

using  System;

using  System.Net;

using  System.Windows;

using  System.Windows.Controls;

using  System.Windows.Documents;

using  System.Windows.Ink;

using  System.Windows.Input;

using  System.Windows.Media;

using  System.Windows.Media.Animation;

using  System.Windows.Shapes;

using  System.Windows.Resources;

using  Microsoft.Xna.Framework.Audio;

using  System.IO;

namespace  AlarmClock


public static class SoundEffects


public static void Initialize()


     StreamResourceInfo info;

info = App.GetResourceStream(newUri(“Audio/whistle.wav”, UriKind.Relative));

Alarm = SoundEffect.FromStream(info.Stream);

CompositionTarget.Rendering += delegate(object sender, EventArgs e)


Microsoft.Xna.Framework. FrameworkDispatcher.Update();


Microsoft.Xna.Framework. FrameworkDispatcher.Update();


public static SoundEffect Alarm { get; privateset; }



  • The complete Interactive Alarm Clock app for Windows Phone 7.5 & Windows Phone 8 source code  is shared here.

What’s New in Windows Phone 8 : A SmartPhone for Smarter People

Windows Phone 8 comes with some of the latest features like fast-fluid Internet Explorer , exciting Live Tiles for Peoples, Contacts hub with Cloud Connected Skydrive , NFC (Near Field Communications) for sharing data between two smart phones, enhanced Nokia & Bing Maps.

Lets connect about new features of Windows Phone 8

%d bloggers like this: