Lets learn about creating Windows Phone Projects

Visual Studio 2010

    • Visual Studio is an “Integrated Development Environment” for creating programs
      • Edit program source
      • Add and manage program resources
      • Build, deploy and debug an application
      • It can be used for multiple platforms and languages and can also be customized by plug-ins for the different target platforms

Windows Phone on Visual Studio

  • Create the Windows Phone Solution
  • Edit the program source files
  • Add and manage program resources
  • Build and run the solution
  • Debug the solution on emulator or device
  • Manage the properties of deployment in marketplace.

Visual Studio Project and Solutions

  • A .NET Program is made up of assemblies
    • An assembly is a library file(.dll) or an executable (.exe) and it contains compiled code and resources (e.g. images and sounds) along with a manifest.
    • The .exe file also contains an entry point (Main)
  • A Visual Studio solution project describes the content of a single assembly
  • A Visual Studio solution is made up of number of projects and at least one of them has an entry point where a program can start
  • A Visual Studio Solution is an XML file that contains reference to the project file that make up solution.
  • Each project contains resources and code which contains single project can be shared amongst multiple solutions also a library assembly can be used in the library.



  • New projects and solutions are created from templates installed in Visual Studio
  • Additional templates can be installed so that the tool can be used to target different platforms
  • These templates give you the basic structure of the type of program you are trying to make and also add the relevant references and saves you a lot of effort.

Making a Silverlight Application

  • Silverlight apps are generally line of business apps which are used to do business with and there is a template that helps us create a Windows Phone Silverlight application.
  • Very easy to create rich user interface.
  • This creates the initial page for our application and configures Visual Studio to target the Windows Phone platform.
  • If we want to create additional pages and add resources to the solution we can do this using Visual Studio.

Note – Windows Phone Mango is called 7.5 but the tools and the OS is called 7.1. The reason being the development team started pretty early and named the OS as 7.1 (after 7.0) but when the marketing team decided that they would call the whole package as 7.5

XNA Game Projects

  • Could be developed in a similar way to a Silverlight app but the starting template needs to be different.
  • The solution structure will be different though.

  • The content project contains all the elements of the game, assets, texts,etc
  • If you have not developed an XNA games before then i would like tell you that
    • An XNA game will not be like a silverlight app in which you press a button but in an XNA game the stuff will be repeated 30 times a second.
    • Its pain free and very well packaged.
    • XNA is great for writing games
    • Makes good use of graphics acceleration
    • Can be tedious to create UI behaviors

Combining Silverlight & XNA

  • It is possible for the silverlight form containing XNA content to hold silverlight components and this makes it possible to overlay Silverlight UI elements on top of an XNA display.
  • This makes it easier to build interfaces to XNA game.
  • Such a project will contain at least three projects
    • SilverXNA – It is the project that actually does the running
    • SilverXNALib – The libraries
    • SilverXNALibContent – XNA library content which will have assets, etc
    • When we make a silverlight and XNA combined program then we will have a page that will take us from the silverlight to XNA. So shown in the image below we will have a single button that will navigate to the game page on clicking.
    • Also this button click starts the XNA game engine.

  • The XNA page as shown below contains version of
    Draw and Update methods that are called to run the game within the silverlight

Multiple Project Solutions

  • A VS 2010 solution can have
    • PC version of XNA game
    • XBOX version of a game
    • Windows Phone Version of a game
    • They can also share code libraries which are also part of solution
    • Many projects can share the output from a single project.

Running Applications on Windows Phone Platform

Windows Phone Device Basics

To connect from a Windows PC to Windows Phone Device we need the Zune software. this could also

  • Synchronize Media
  • Perform Phone Updates
  • The download is available at http://zune.net
  • Before we deploy our application on Windows Phone we need to register it as a developer device. This registration is a one time process and the registered developers can register up to 3 devices (but registered students can register only one device).
  • Now you need to connect the phone to your PC and from the drop down as shown below we can select the Windows Phone 7 Device

  • The debugging method and development environment is the same for both the WP devices and Emulator.
  • The problems that you might face while deployment might be
    • If the phone is displaying lock screen deployment will fail.
    • Applications that use media will not work correctly if they are deployed when the Zune software is running. To solve this problem we can use “Windows Phone Desktop Pass- Through” program to connect instead of Zune. It is available with SDK.
    • Once the application is deployed it will be stored on the device for later use but remember at a time you can have only 10 of your own applications on the phone at any time. You can anyways send the compiled version of your application to other registered developers for them to use on their developer devices.

Emulator Basics

  • Emulator is available with Windows Phone SDK.
  • It runs as a program on the windows PC.
  • It has the same software as Windows Phone device but is targeted to run on Windows PC platform.
  • The Emulator
    • Has a browser
    • Will provide phone behaviors for things like placing calls and sending SMS. Also it has some entries in phonebook
    • Contains emulation of windows phone camera, GPS and motion sensors
    • Has the ability to capture screenshots of programs running on the phone.
    • If you are developing a game then it is recommended to run it on the phone as the performance is something which is not properly tested on emulator as it running in Windows environment.
    • You can use a PC mouse to touch on the screen.
    • If you have a multitouch monitor then that touch can be passed to the emulator as well.
    • If you want to use the PC keyboard for typing then you should use the Pause/Break key to toggle the emulator keyboard. When the Emulator keyboard is not there it will take the input from PC keyboard.
    • The windows Phone Emulator
      • Does not support Zune media playback.
      • Uses only only the built in browser application.
      • Should be used for functional testing only.
      • When you hover over the emulator with a PC mouse you will see an extra set of tools.
        • These allow you to rotate the emulator into different orientations
        • There are two landscape positions but only one portrait position.

  • The camera can also be emulated but it can take a simple photograph and return it.
  • Location Emulation also works now with Mango version. The location tab is shown below and you can click the location move the emulator to that position and also place pushpins to describe a route and then replay the route as well.

  • Windows Phones contains an accelerometer and compass that can be emulated as well for determining the position.

  • Also you can take screenshots in Windows Phone and the same can be emulated as well

Program Debugging

  • We can add breakpoints
  • We can use Single Stepping
  • We can use the Immediate Window


Your feedback and comments are welcome.



So the topics we are going to cover in this post are:

  • Windows Phone Task Management
  • Multi-Tasking with Background Agents
  • Creating tasks in Visual Studio
  • File Transfer Tasks
  • Background Notifications
  • Background Music Playback Tasks


  • Must have .Net and Silverlight development experience
  • Must have developed a windows phone apps.

Lets start


Windows Phone Task management

Forground Tasks

  • Normally a windows phone application runs in the foreground and interacts with the screen and user of the phone
  • There is only one foreground application active at a time though other may be running but are not active. This ensures better battery life for the user.

Background Tasks

  • A Windows Phone application can have only one background agent which can perform perodic tasks or resource intensive tasks or both.
  • The Agent can run when the application is not in the foreground.
  • The background tasks have limitations to what it can do and processor and other phone facilities. The logical reason that microsoft architect give is that if a background tasks goes out of control or does what it is not intended to do somehow it should not affect the battery life of the phone and the user user experience as well.
  • A background task can be used used to conatc the datbase and get the updates every half an hour or play music from a server online.

Background Agent Health Warning

  • There can only be limited number of background agents running at a point of time and this controlled by the oprating system.
  • A background agent will be started only when the operating system can give the agent processor resource.
  • If the phone goes to power saver mode then the background agents may stop running.
  • Also at any point of time the user can see the background tasks running and can manage them and choose to disable them.
  • So dont put any critical logic in background agent as it may not run. Its like icing on cake.

Multitasking with background agent

Agents and Tasks

  • The Agent is the container that is manged by the operating system and agent is the code that will run.
  • There are two kinds of tasks
    • Perodic
      • Will run every now and then (typicallyevery 30 minutes or so).
      • Intended to perform a task that runs regulary and complts quickly
      • Phone will have of limit on how many of them can be running.
      • Good for location tracking tracking and polling background services.
    • Resource intensive
      • Will run when the phone is in a postion to let them. This means it will run when
        • The phone is connected to mains
        • The phone is connected to Wi Fi
        • The phone is not being used (lock screen is displayed)
      • So if you rellay need this to run you need to made some recomendations to the user so that this resource intensive task runs successfully.
      • A Resource intensive agent can run upto 10 minutes.
      • Good for synchronization with host service, unpacking / preparing services, compressing database.

Dual Purpose Agents

  • An application can run both periodic and resource intensive tasks.
  • Can be achived though single background agent class.
  • When the agent start it can determine in which context it is running and behave appropriatly.

Creating tasks in visual studio

Creating an application

  • Lets Create a captians log application which will be a simple logging application.
    • Users can type log entries which are timestamped and stored in an isolated storage.
    • The tracking feature will be added using background agent.
    • The start tracking button click will fire up the background agent will be track the location of the captain and add it to the log. So the agent will update the position even when the program is not active.

  • Create a Windows Phone application solution and develop the foreground tasks and applications.
  • Add a new project to the application solution which is Windows Phone Scheduled task (VS Template). This will contain code will run when the agent is active.

  • Here is the solution file for the captians log which has got two projects:
    • Captians Log – The Windows Phone Silverlight Project which is the main application.
    • LocationTaskAgent – The background agent to perform the tracking.
  • Solutions may contain differnt projects and when the soltion is build all the assembly file outputs will be combined and sent to the phone.

  • Before this works we need to refernce the LocationTaskAgent Project in Captains Log

  • And when we do this the application manifest file adds a little bit of text to hold the description of the background agent and this is how the background agent is bound to the application. Here is the text added to the application manifest file.

  • So below is the code that will run when the agent wakes up so we need fill this OnInvoke method with our code that the agent will run. At the end to this code we need to call the method notify complete whcih will will notify the runtime system that it is done.

  • The Captains log datafile is shared between the application and agent and the first thing that the agent will do is load this datafile from the isolated storage.

  • Now we make use of GPS traking to find out the current loaction. So we make GeoCoordinateWatcher and start it and use it to get the location. Now before you start thinking about the performance hit this does i would like to tell you that there is a special version of this class provided for Background Agents which uses cached location data which is stored every 15 minutes.

  • And then agent just stores back this location to the application and goes to sleep.

  • Finally a notification is displayed to the user on which the user can click and go to the main application.

File transfer tasks

  • It is possible to create a background task to transfer files to and from application’s isolated storage.
  • The transfer will take place when the application is not running.
  • An application monitor the state of downloads and display their status
  • Files can be transferred from http or https hosts (ftp is not suppoerted currently)
  • The system maintains a queue of active transfers and services each one in turn.
  • Applications can query the state of active transfers.

Background Transfer Policies

  • Policies are :
    • Maximum upload file size is 5Mb
    • Maximum download file size over cellular (mobile phone) data : 20Mb
    • Maximum dowload file size over WiFi : 100Mb
  • These can be modified by settng the value of TransferPreferences on a particular File Transfer.

Background Transfer Namespace

  • The background transfer namespace is :

  • All the background transfer services are provided from the BackgroundTransfer namspace
  • Most instertingly you dont need to create additional projects to manage background transfers.

Create a Background Transfer

  • The following code creates a request and sets the source for transfer and it also sets the transfer method.

  • The following code sets the destination of the files transfer which is isolated storage of the application. Also it sets the preferences for the transfer. Now the transfer preferences can have multiple string so that you can set multiple properties.

  • The following code starts the transfer request by adding it to the list of active transfers. Also catches the exception if any and shows a message if it cannot proceed with the transfer.

  • The following code monitors the transfer by binding the methods to the events fired by the transfer request.


  • You can also kill the transfer by using the following code:

  • Windows phone appplication at any point of time can find out how many active transfers does have and as a rule of thumb you should always check the same whenever your application restarts because your transfers are still running when your application is not active. Below is the code that lets you do the same.

Scheduled Notifications

  • Windows phone app can create scheduled notifications and they are displayed when the application is running or not.
  • When the notification is diplayed the phone user has the option to respond to it or not. Also the notification can be liked to an application page.
  • The notifications can fire once or repeatedly at configurable intervals.
  • The notifications is maintained by phone operating system, once the application can started then it doen not have to do anything.

Sample Application

  • Lets make a simple timer application which will have two silverlight pages.
  • The user will set the time using the slider then preses the start timer button to create a notification.
  • When the notification will fire the 2nd page of the application which is egg ready page will be displayed and if the user clicks on the same then user will be taken to the application.
  • The sceen of the application will look something like this:

  • The code for the creating the reminder is as below. This code will create the reminder and then adds it as a sceduled service. The value eggTime holds the lenght of the delay and this code also sets the url of the page in application.

  • And before you add the reminder you need to check if its already present in the memory and if the that is the case it is removed from the memory. The code for doing that is as below:

Audio Playback Agents

  • It is possible to create a playback that will manage an application playlist and the mechanism is the same as for other background tasks.
  • The audio can be streamed or stored in application’s isolated storage.

  • This would also work pretty much like the things shown above in the post so i am not elaborating it.


You are free to ask any questions or leave your comments here…


Creating a Simple Download Manager For Window Phone 7

Start by creating a C# Windows Application project in Visual Studio and on the form drag 3 labels, 2 textboxes, 2 buttons and one progressbar.

As you can see in the form above, the first two labels are just for describing the role of the first two textboxes which are named txtUrl and txtPath. They will obviously hold the URL of the file we want to download and the local path (and filename) to where we want to save it. The default values I set in the project will download a short video from Microsoft’s Channel 9 website to C:\Filename.wmv.
The two buttons – btnDownload and btnStop – are used for starting and stopping a download, while the label below them – lblProgress – is used for showing the current progress of the download in bytes and percentage. Finally, the ProgressBar located at the bottom of the form is entitled prgDownload and it display the progress of the download on a scale from 1 to 100.

Now let’s get into coding. Switch to code view, and the first thing we need to do is to add a few using statements for the namespaces we’re going to use. Add the following 3 lines below the already existing using statements:

 1: using System.Net;
 2: using System.IO;
 3: using System.Threading;



System.Net will be used for connecting to the web server, System.IO will be used for saving the file to the hard drive, and System.Threading will be used for the thread in which we’re going to put the downloading process.

Inside the form’s class, right above the constructor, add the following lines:

 1: // The thread inside which the download happens
 2: private Thread thrDownload;
 3: // The stream of data retrieved from the web server
 4: private Stream strResponse;
 5: // The stream of data that we write to the harddrive
 6: private Stream strLocal;
 7: // The request to the web server for file information
 8: private HttpWebRequest webRequest;
 9: // The response from the web server containing information about the file
 10: private HttpWebResponse webResponse;
 11: // The progress of the download i ain percentage
 12: private static int PercentProgress;
 13: // The delegate which we will call from the thread to update the form
 14: private delegate void UpdateProgessCallback(Int64 BytesRead, Int64 TotalBytes);



As you can see, we are creating a few objects that we’re going to use later in the code. The object that stands out the most is not really an object, but a delegate: UpdateProgressCallback – this delegate will be used to call a method you’ll see later in our code – UpdateProgress – from inside the thread. Because you see, from inside a thread we can’t update the form elements directly (the label and the progress bar), so we need to create a delegate first, that takes the same arguments as the method. In our case the arguments are two Int64 variables that hold the number of bytes we downloaded from the server by now, and the number of total bytes the file has. Int64 is needed because this number can be really big.

Now let’s review the biggest piece of the code. The one where the file actually gets downloaded. We’ll put this code in a method called Download() which we’re going to call in a thread when the download button is pressed. Here goes the method, below it there’s more explanation of the code:

 1: private void Download()
 2: {
 3: using (WebClient wcDownload = new WebClient())
 4: {
 5: try
 6: {
 7: // Create a request to the file we are downloading
 8: webRequest = (HttpWebRequest)WebRequest.Create(txtUrl.Text);
 9: // Set default authentication for retrieving the file
 10: webRequest.Credentials = CredentialCache.DefaultCredentials;
 11: // Retrieve the response from the server
 12: webResponse = (HttpWebResponse)webRequest.GetResponse();
 13: // Ask the server for the file size and store it
 14: Int64 fileSize = webResponse.ContentLength;
 16: // Open the URL for download 
 17: strResponse = wcDownload.OpenRead(txtUrl.Text);
 18: // Create a new file stream where we will be saving the data (local drive)
 19: strLocal = new FileStream(txtPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);
 21: // It will store the current number of bytes we retrieved from the server
 22: int bytesSize = 0;
 23: // A buffer for storing and writing the data retrieved from the server
 24: byte[] downBuffer = new byte[2048];
 26: // Loop through the buffer until the buffer is empty
 27: while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
 28: {
 29: // Write the data from the buffer to the local hard drive
 30: strLocal.Write(downBuffer, 0, bytesSize);
 31: // Invoke the method that updates the form's label and progress bar
 32:             this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { strLocal.Length, fileSize });
 33: }
 34: }
 35: finally
 36: {
 37: // When the above code has ended, close the streams
 38: strResponse.Close();
 39: strLocal.Close();
 40: }
 41: }
 42: }


The first line inside the method mentions that inside this method we’ll be using the wcDownload object, which can be disposed after we’re finished. If any error happens within the code, we have a finally block which closes the streams to prevent keeping a connection opened uselessly and to prevent the local file from being locked by the code.

Inside the try block we first retrieve information about the file using HttpWebRequest and HttpWebResponse objects. Note that some servers don’t give information about the size of the file, case in which we can only download blindly. If the web server did not return any information regarding the size of the file, webResponse.ContentLength will return -1.

After we get the size of the file, we define the stream that retrieves the bytes from the server, and the stream that saves the file to the hard drive. Before starting to stream the bytes down the cables, we create a buffer where we store the data that is written to the hard drive file. The buffer is 2048 bytes in size, but you can change it to a different value if you prefer.

In the while loop we loop through the buffer and write the content of the buffer to the file on the local drive. We also use the Invoke method of the form to call UpdateProgressCallback (the delegate of UpdateProgress). In the array we pass two parameters that UpdateProgress accepts: how much we downloaded until now (by measuring the length of the local stream), and how big the total file is. If you don’t have any knowledge of threading in C#, you probably would have guessed that you can update the form elements (labels, progress bars, etc.) directly, but for good enough reasons you can’t.
If we were to call the Download() method directly, then we wouldn’t have to use this.Invoke to call the UpdateProgress method. Speaking of UpdateProgress, let’s see how this method looks like:

 1: private void UpdateProgress(Int64 BytesRead, Int64 TotalBytes)
 2: {
 3: // Calculate the download progress in percentages
 4: PercentProgress = Convert.ToInt32((BytesRead * 100) / TotalBytes);
 5: // Make progress on the progress bar
 6: prgDownload.Value = PercentProgress;
 7: // Display the current progress on the form
 8: lblProgress.Text = "Downloaded " + BytesRead + " out of " + TotalBytes + " (" + PercentProgress + "%)";
 9: }


We do a simple math calculation to get the percentage (0 to 100) and we set it on the ProgressBar to reflect the progress. We also set the label with information on the progress of the download.

We’re done with the methods for this application, now we only need to create the two event handlers for the Download and Stop buttons. Double clicking btnDownload in Visual Studio 2005 will create the Click event handler for you. Use the following code:

 1: private void btnDownload_Click(object sender, EventArgs e)
 2: {
 3: // Let the user know we are connecting to the server
 4: lblProgress.Text = "Download Starting";
 5: // Create a new thread that calls the Download() method
 6: thrDownload = new Thread(Download);
 7: // Start the thread, and thus call Download()
 8: thrDownload.Start();
 9: }


In the code above we start a new thread, to which we pass the name of the method (without the parenthesis). Then we start the thread. The reason we need to use a thread and we can’t just call the method from inside the Click event is because in that case our application would completely hang while downloading the file. It would become unusable and unresponsive, as if it crashed.

Finally, we have the code for the stop button:

 1: private void btnStop_Click(object sender, EventArgs e)
 2: {
 3: // Close the web response and the streams
 4: webResponse.Close();
 5: strResponse.Close();
 6: strLocal.Close();
 7: // Abort the thread that's downloading
 8: thrDownload.Abort();
 9: // Set the progress bar back to 0 and the label
 10: prgDownload.Value = 0;
 11: lblProgress.Text = "Download Stopped";
 12: }


To make this a real download manager, we’d have to add resume options, and a download list so that we give the user the option to download multiple files at once, or schedule them. This will be covered in a future tutorial.

Below is the entire source code of Form1.csthat you can also view in the Visual Studio 2005 project files attached to this tutorial.

 1: using System;
 2: using System.Collections.Generic;
 3: using System.ComponentModel;
 4: using System.Data;
 5: using System.Drawing;
 6: using System.Text;
 7: using System.Windows.Forms;
 8: using System.Net;
 9: using System.IO;
 10: using System.Threading;
 12: namespace DownloadManager
 13: {
 14:    public partial class Form1 : Form
 15: {
 16: // The thread inside which the download happens
 17: private Thread thrDownload;
 18: // The stream of data retrieved from the web server
 19: private Stream strResponse;
 20: // The stream of data that we write to the harddrive
 21: private Stream strLocal;
 22: // The request to the web server for file information
 23: private HttpWebRequest webRequest;
 24: // The response from the web server containing information about the file
 25: private HttpWebResponse webResponse;
 26: // The progress of the download in percentage
 27: private static int PercentProgress;
 28:       // The delegate which we will call from the thread to update the form
 29: private delegate void UpdateProgessCallback(Int64 BytesRead, Int64 TotalBytes);
 31: public Form1()
 32: {
 33: InitializeComponent();
 34: }
 36: private void btnDownload_Click(object sender, EventArgs e)
 37: {
 38: // Let the user know we are connecting to the server
 39: lblProgress.Text = "Download Starting";
 40: // Create a new thread that calls the Download() method
 41: thrDownload = new Thread(Download);
 42: // Start the thread, and thus call Download()
 43: thrDownload.Start();
 44: }
 46:    private void UpdateProgress(Int64 BytesRead, Int64 TotalBytes)
 47: {
 48: // Calculate the download progress in percentages
 49: PercentProgress = Convert.ToInt32((BytesRead * 100) / TotalBytes);
 50: // Make progress on the progress bar
 51: prgDownload.Value = PercentProgress;
 52: // Display the current progress on the form
 53: lblProgress.Text = "Downloaded " + BytesRead + " out of " + TotalBytes + " (" + PercentProgress + "%)";
 54: }
 56: private void Download()
 57: {
 58:       using (WebClient wcDownload = new WebClient())
 59: {
 60: try
 61: {
 62: // Create a request to the file we are downloading
 63: webRequest = (HttpWebRequest)WebRequest.Create(txtUrl.Text);
 64: // Set default authentication for retrieving the file
 65: webRequest.Credentials = CredentialCache.DefaultCredentials;
 66: // Retrieve the response from the server
 67: webResponse = (HttpWebResponse)webRequest.GetResponse();
 68: // Ask the server for the file size and store it
 69: Int64 fileSize = webResponse.ContentLength;
 71: // Open the URL for download 
 72: strResponse = wcDownload.OpenRead(txtUrl.Text);
 73: // Create a new file stream where we will be saving the data (local drive)
 74: strLocal = new FileStream(txtPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);
 76: // It will store the current number of bytes we retrieved from the server
 77: int bytesSize = 0;
 78: // A buffer for storing and writing the data retrieved from the server
 79: byte[] downBuffer = new byte[2048];
 81: // Loop through the buffer until the buffer is empty
 82: while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
 83: {
 84: // Write the data from the buffer to the local hard drive
 85: strLocal.Write(downBuffer, 0, bytesSize);
 86: // Invoke the method that updates the form's label and progress bar
 87:                   this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { strLocal.Length, fileSize });
 88: }
 89: }
 90: finally
 91: {
 92: // When the above code has ended, close the streams
 93: strResponse.Close();
 94: strLocal.Close();
 95: }
 96: }
 97: }
 99: private void btnStop_Click(object sender, EventArgs e)
 100: {
 101: // Close the web response and the streams
 102: webResponse.Close();
 103: strResponse.Close();
 104: strLocal.Close();
 105: // Abort the thread that's downloading
 106: thrDownload.Abort();
 107: // Set the progress bar back to 0 and the label
 108: prgDownload.Value = 0;
 109: lblProgress.Text = "Download Stopped";
 110: }
 111: }
 112: }

Please Do comment ,if you liked my tutorial.

Hey Guys. Hope you liked my previous post for creating a simple Windows Phone 7 navigation application.

So in this post we will learn as how how can we optimize the virtual keyboard on WP7 for various input controls.

Open the solution we created in the previous post for creating a simple Windows Phone 7 navigation application or else you can download the solution here.

  • Now open contact.xaml in Expression Blend and go to the ContentPanel inside LayoutRoot. Now open the properties of ContentPanel and expand the layout properties and then set the VerticalScrollBarVisibility to Auto




  • Select ContentPanel in the design surface in the centr and then double click the grid contol in the toolbar. This will add a grid inside the ContentPanel. Now right click the grid and select AutoSize –> Fill.




  •  Now just just drang and drop TextBlocks and TextBoxes as show in the image below:

    TextBoxes & TextBlocks

    TextBoxes & TextBlocks

  • Now come the coolest feature in input controls. It is a property called InputScope. Now select the TextBox for Phone and go to properties –> common properties –> InputScope and set it to TelephoneNumber. Similarly change the testbox properties of other contols to below specified values and you will see the magic when you run the application and all this is done without writing any code.

            First Name textbox: Set InputScope to PersonalGivenName
Last Name textbox: Set InputScope to PersonalSurName
Email textbox: Set InputScope to EmailUserName
            Web Site textbox: Set inputScope to Uri
            Address textbox: Set InputScope to AddressStreet
            City textbox: Set InputScope to AddressCity
            State textbox: Set InputScope to AddressStateOrProvince



  • Now while setting the input scope you might have seen a large number of options but thats not the full list. The full list of the InputScope instances is below:

    InputScope instances

    InputScope instances

Download the source code by clicking on the button [button link=”http://minus.com/mV0RoTjnG” style=”download” color=”green”]Download Source Code[/button]
Do let me know your feedback on this post. Thanks

[highlight]Create a simple navigation application in Windiows Phone 7 ( WP7 ) [highlight]

In a Windows Phone application it is highly probable that you will have more than one screen in your application and you will need to navigate between them. We can make use of the navigation framework for the same. This navigation will be very similar to navigating from one web page to another. This navigation framework also supports query string.

So without much talk let’s go ahead and create a simple business information application of financial company ACME and learn navigation in WP7.

  • Goto visual studio 2010 and create new Windows Phone Silverlight and XNA Applicationand name it NavigationExample.

    Create Application

    Create Application

  • Add new folder to the NavigationExample named Views and inside Views add a new folder Locations.

    Add Folder

    Add Folder

  •  Now add Windows Phone Portrait Page named About and Contact in the Views folder

  • Similarly add Windows Phone Portrait Page named Corporate Office and Satellite office in the Locations folder.

    Windows Phone Portrait Page

    Windows Phone Portrait Page

  • Now lets open the pages and edit the default text on the pages.
  • Open MainPage.xaml and edit the text to as shown in the image below. Also drag and drop four HypelinkButton onto the MainPage.xaml



  • Now edit the HyperlinkButtons to point to the proper pages to be navigated. Use the image below to do the same.MainPage.xaml



  • Now open about.xaml, contact.xaml, corporateoffice.xaml, satelliteoffice.xaml and edit the headings.
  • Now run the application and you will see the screen as below. You can also navigate to different screens.
Navigation Example

Navigation Example

You can download the full source code here

Please remember to leave your feedback or appreciations or questions. Thanks