Friday, January 6, 2012

Create Project Hello Project - 1

Create Project

Once we are done with setting up the development environment, we are ready to create our first project. Open Visual Studio 2010 and create New project. In the "New Project" dialog Window:

  1. Select "Silverlight for Windows Phone" from the left panel. The respective templates will filter out in the right panel.
  2. As we are creating a new Application project, select "Windows Phone Application" from the right panel.
  3. Enter a name and path for the project.
  4. Click "OK" to continue.

Have a look into the below screenshot for reference:

image

A second dialog will popup asking you to chose the target version for our application. We will chose "Windows Phone 7.1", which is the latest version. Click "OK" to continue creating the first project.

image

This will create the project for you. In the Solution Explorer, you will notice that, the project has one App.xaml and it's associated CS file, a MainPage.xaml and it's associated CS file, three JPG images named as "ApplicationIcon", "Background" and "SplashScreenImage". No need to explain more on this as the names are self explanatory.

image

Analysis of Code

Lets start doing the analysis with the existing XAML code that is present in the MainPage.xaml file. On creation of the project, the IDE template will create the default XAML inside MainPage.xaml file.

Here is the complete code of that:

 
<phone:PhoneApplicationPage 
    x:Class="HelloWorld.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">
 
    
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        Grid.RowDefinitions>
 
        
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" 
                       Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" 
                       Style="{StaticResource PhoneTextTitle1Style}"/>
        StackPanel>
 
        
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">Grid>
    Grid>
 
    
    
 
phone:PhoneApplicationPage>

If you check, it has a Grid with 2 rows. The first one is to set the title of the page and the second one is to set the content of the page.

If you proceed to the next code placed just below of it, you will see a StackPanel having two TextBlock inside it. The first TextBlock contains title of the Application and the second TextBlock contains title of the Page. Here is the code snippet of the same:

image

If you go little bit more, you will find another Grid placed in the second Row. This is nothing but the content area. You can place any content here. Here is the screenshot of the same code snippet:

image

If you go in depth more, you will find the below commented code:

image

What is that commented code? This is the part for Application Bar. You can place additional buttons specific to your application. You can also place menu items in this section to do some specific tasks. We will discuss on it in later posts.

Playing with the Code

Now time to play with the code. Let us add the application title and page title there. Go to the Title Panel and modify the XAML code like this:

image

Let's run the application now. You will see that, it will open the Windows Phone Emulator on the screen. After the loading completes, it will show the application page in the UI. There you will notice that, it has the proper title for the Application and Page.

In our example, "Hello World App" is the Application title and "Home Page" is the page title. Have a look into the below screenshots for more details:

imageimageimage

Lets add a TextBlock as the content of the page. To do this, go to the ContentPanel and add a TextBlock as shown below:

image

If you run the application now, you will see the below UI in the Windows Phone Emulator containing the content text:

image

Application List

If you want to see the hosted application in the Emulator, you can do that too. This step will show you how the application will look in the installed application list. Follow the below steps to see it in action:

imageimageimage

In emulator, you will see a Back button as shown in the first screenshot. Click it and that will navigate you to the Home Screen. As shown in the second screenshot, click the small arrow marked with the circle above. You will navigate to the installed application list. There you will find our "Hello World" application listed there as shown above.

Introduction and Prerequisities of Windows Phone 7

Introduction:

Before starting with the development process of the Windows Phone 7, let’s seen on what the prerequisites are required.

Software Requirement:

Hardware Requirement:

Below are the minimum requirements for windows mobile phone 7 manufacturers taken into consideration in order to maintain some standard across the manufacturers.

Hardware

Description

Display WVGA (800 x 480) Should have a minimum resolution of 800X480 for providing a good user interface.
Multi Touch (4 Ways) This is for providing option for multi user processes like accessing shared portion, used for games etc
DirectX 9 Acceleration This is specifically for the GUI based processes, like games, rich user application to maintain the standards.
Global Positioning System(GPS) This is for providing location specific processes like GPS navigator, to integrate with Maps etc.
Accelerometer This is for providing the proper acceleration of the device normally used in games, location-based applications.
Compass This is for detecting the position like North, South, East, and West.
Light This is for using like a Flash light in the phone. Also we can enhance to use it across some external application for flash
Camera This is for taking pictures that can be stored and accessed online, also to integrate with the social networking sites like Facebook, Twitter etc.
Button Controls(Up, Down, Side buttons) This is for providing the functionality that normally all phone will have like attending the call, navigation etc.
Network Connection This is for providing the connectivity process like normal phones to make calls, text and similar purposes.
Data Connection This is for providing the functionality of internet to the phone with the technologies of 2G, 3G etc.
256 MB of RAM This is the base requirement for a windows phone 7 manufacturer because 90 MB of memory can be used by the application our of 256Mb. This is strictly followed if fails then the application will fail in the Market Place
8GM flash storage This is for the storage among the applications

Windows Phone Platform:

Microsoft has provided windows phone 7 with existing .net core functionalities and libraries like Threading, LINQ, Multi threading, XML programming, Security, Reflection , Localization and Globalization. Apart from these available resources in Windows Phone 7 they have added 2 more major frameworks: Silverlight and XNA.

Silverlight:

Silverlight is basically used for light weight business applications and normal 2D games development using the XAML (Extensible Application Markup Language) Programming. Developers will have much flexibility using this framework along with much used UI tools like Microsoft Blend, Adobe Photoshop etc. to create a vector based process that can be easily transported to XAML. This is really a not new topic compared to the XNA development since Silverlight is already in market for developing rich browser applications and it provides an option of creating applications with XAML which is highly advantageous of creating a vector based application. So it gives the developers on full control of the layout, design, structure and also the data binding components.

XNA:

XNA is basically used for developing rich games where the framework comes with a game engine (with 3D) which helps the game developers to provide rich 3D games. Unlike Silverlight XNA is not much known across the developers since it has been used to develop Xbox games using Managed code. Why Microsoft provided the XNA engine with the windows phone 7 is mainly because of integration of Xbox live integration with Windows Phone 7. XNA engine provides the rich user experience that ever y developers take advantage in providing next generation games with 2D and 3D game loop engines.

Using Azure:
When we create an application with Windows Phone 7, we need to save some data for future retrieval which is going to be bit tough here. Windows phone 7 doesn’t provide the direct connectivity with database to save the data. To overcome this we need to use AZURE, Windows azure provides the platform of Cloud Computing in storing and retrieving the data from different locations using Windows Phone 7. Say today we created a small application in windows phone 7 using Silverlight. Day to-day when the development increases and finally we get an excellent product, then the number of user visit gets increased which eventually requires an enterprise database to save the details. So at this case we can use the Azure availability of extending the size of the database as per the need since it maintains in the cloud. If we use Azure for the development of the Windows Phone 7, Microsoft has provided with an additional advantage of using Bing Maps which is given free of cost only for the windows phone 7. Additionally Push notification services are also been provided in the cloud where we can use it to send notifications to the mobiles as Text which is eventually a bitter process for the business needs.

Development Life Cycle:

We as developers of windows phone 7 we need to register with App hub using the below link http://create.msdn.com/en-US/ and giving our Windows Live credentials which acts like a single sign on for all the process which Microsoft provides. The main idea behind registering with App hub is once registered and developed an application in Windows Mobile phone 7 we can use our registered hand set as a physical device tester to test our application. App Hub provides developers with up to 3 devices can be registered and test it in real-time.
Now let us jump through the steps involved in the application development life cycle of the windows phone 7.
Step 1 – Register with App Hub
As mentioned above App hub is the Microsoft place where we need to register and use for testing the application in real-time. Please follow the below steps to register in App Hub.
Steps to register the APP HUB
Step 2 – Market Place Certification procedures.
Once we are registered with the App Hub, before proceeding with the development consider reading the certification process document in order to avoid rejection of the product at the market level. Please refer to the below link for the Application Certification process checklist and validation.
http://go.microsoft.com/?linkid=9730558
Once the development is completed and the validation process is checked and passed by the Market, then the application will be available online for downloads. Microsoft reserves the rights to give 5 free applications downloads and unlimited number of paid application downloads.
Microsoft charges an amount of 99$ for the market place registration to submit the application developed. And for each download the Microsoft takes 30% of the fees paid and the developer will get 70% for his development charge.

Conclusion:

In this article we have seen on the prerequisites required before starting development process with windows phone 7.

Learn Windows Phone 7 Development in 31 Days

Friends,

Right now I am working on a new series of articles on Windows Phone 7. These articles are for the Novice to get exposed and be a Professional with Windows Phone 7 Development. The article covers in-depth and the step by step process on how to set the development environment and make use of the inbuilt controls available to develop the Windows Phone 7 Application. I am not going to limit these with the numbers provided below, but still as a start up I have targeted these 31 topics and to give my readers a fair idea on these topics.

I would like to get continued with the sort of feedback provided by my readers so that I will provide my best to the community. Below is the agenda for the list of topic that will be covered in this series on Windows Phone 7.


Topics

Learn Windows Phone 7 Development in 31 Days – Day 1 – Overview and Requirements of WP7
Learn Windows Phone 7 Development in 31 Days – Day 2 – Creating a Hello World Silverlight Application in WP7
Learn Windows Phone 7 Development in 31 Days – Day 3 – Using Expression Blend to Design the WP7 Application
Learn Windows Phone 7 Development in 31 Days – Day 4 – Create a local database in WP7 and how to use it
Learn Windows Phone 7 Development in 31 Days – Day 5 – Create a local database with MVVM in WP7
Learn Windows Phone 7 Development in 31 Days – Day 6 – Using Files and Folders in WP7
Learn Windows Phone 7 Development in 31 Days – Day 7 – Consume a ODATA service in WP7
Learn Windows Phone 7 Development in 31 Days – Day 8 – Encrypt and Decrypt in WP7
Learn Windows Phone 7 Development in 31 Days – Day 9 – Localization and Globalization in WP7
Learn Windows Phone 7 Development in 31 Days – Day 10 – Application Bar usage in WP7
Learn Windows Phone 7 Development in 31 Days – Day 11 – Working with Alarms/Reminders in WP7
Learn Windows Phone 7 Development in 31 Days – Day 12 – Background File Transfers in WP7
Learn Windows Phone 7 Development in 31 Days – Day 13 – Working with Camera in WP7
Learn Windows Phone 7 Development in 31 Days – Day 14 – Working with Contacts in WP7
Learn Windows Phone 7 Development in 31 Days – Day 15 – Working with Calendar in WP7
Learn Windows Phone 7 Development in 31 Days – Day 16 – Working with Bing Map Control in WP7
Learn Windows Phone 7 Development in 31 Days – Day 17 – Working with Panorama Control in WP7
Learn Windows Phone 7 Development in 31 Days – Day 18 – Working with Pivot Application Control in WP7
Learn Windows Phone 7 Development in 31 Days – Day 19 – Working with Web Browser Control in WP7
Learn Windows Phone 7 Development in 31 Days – Day 20 – Working with Media in WP7
Learn Windows Phone 7 Development in 31 Days – Day 21 – Working with Toast Notification in WP7
Learn Windows Phone 7 Development in 31 Days – Day 22 – Working with Tile Notification in WP7
Learn Windows Phone 7 Development in 31 Days – Day 23 – Working with Raw Notification in WP7
Learn Windows Phone 7 Development in 31 Days – Day 24 – Working with Search Extensibility in WP7
Learn Windows Phone 7 Development in 31 Days – Day 25 – Working with Tiles in WP7
Learn Windows Phone 7 Development in 31 Days – Day 26 – Working with Navigation in WP7
Learn Windows Phone 7 Development in 31 Days – Day 27 – Working with Launchers and Choosers in WP7
Learn Windows Phone 7 Development in 31 Days – Day 28 – WP7 Application Life Cycle Overview
Learn Windows Phone 7 Development in 31 Days – Day 29 – Calculating routes using BING Map Control in WP7
Learn Windows Phone 7 Development in 31 Days – Day 30 – Installing and using WP7 Tool kit for Silverlight
Learn Windows Phone 7 Development in 31 Days – Day 31 – Deploying the application to the WP7 Market place

Watch out my blog on these tutorial series and hope it will be useful for my readers.

Happy Coding!!!