Your First Windows Phone 7 Application Solution Explorer Overview
Ok, so you picked File > New Project under Visual Studio menu and from the New Project dialog box you chose to create Windows Phone Application type project. Once Visual Studio prepares the stage for you (considering this is your first interaction with Windows Phone 7 application) you see a lot of items you are unfamiliar with,
In this post I will walk you through briefly with each item that make up a standard windows phone application.
Images
A basic application requires following three image resources,
ApplicationIcon.png : This icon is per application and is displayed in Windows Phone applications list (quick launch screen). Under the phone applications list, a recommended icon size of 62 x 62 fits well with other applications.
You are allowed to use any other name for this icon file and to change that look for following line under WMAppManifest.xml file,<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
Background.png : Windows Phone allows you to pin your favorite applications for future easy access. Once you pin an application, a large icon for that application is displayed on the start screen (as shown below). Backround.png refers to this pinned application image displayed on the start screen. Even if the provided image resolution is greater than 173 x 173 (standard size), the Phone 7 OS will adjust the resolution and show a 173 x 173 resolution image. The image format must be a PNG.
Just like ApplicationIcon file, the reference to this file is found under WMAppManifest.xml file as following,<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
<Count>0</Count>
<Title>Test Application</Title>
The count is an integer value and is useful to be manipulated during execution if the application nature allows multiple instances be pinned at a time. The count specified appears on the top right of the image as shown in pinned image below,
Title as the name suggests is shown as the title of the application for a pinned application.
SplashScreeenImage.jpg : Just as the name suggests, this screen is loaded every time you launch an application to act a preloader.How to Pin an application?
Click and hold the mouse on application icon unless the slider pops up,
How to Un-Pin an application?Click and hold the mouse unless the application icon pops out with un-pin icon with mouse,
PropertiesContained within the Properties folder you will find,
AppManifest.xml : This file is a must part for a “XAP” package submission under Windows phone market place and contains reference to the assemblies used in the application. Note that these references are not be listed in the file unless the XAP package is built thus if you open this file under Visual Studio you will find empty <Deployment.Parts> tag.
Once you build the project the references are automatically listed in the output file. To take a deeper look at how references are injected in this file, build your application and take a look at the contents of this file found under \Bin\Debug or \Bin\Release folders.
AssemblyInfo.cs : Just like a standard windows project, the assembly information file contains information about project title, description, company, trademark, copyright, etc which upon successful build is made part of the output DLL. This file can either be edited directly or from Assembly Information dialog box triggered from project properties console,
WMAppManifest.xml : Just like AppManifest.xml this is also another integral file for package submission in windows phone market place. However where AppManifest.xml file references assemblies for the application execution only, this file is responsible for configuring your application on a windows mobile by specifying following,
- Application Title, Version, Author, Publisher and Target platform information
- Application icons for quick launch and start screen
- Windows Phone hardware capabilities available to this application like communication with network, web browsing, microphone and others. Based on the capabilities defined here, the application is granted access to utilize those features.
App.xaml : This file is the design time for the application itself. In the design time declaration you specify the application object referenced by </Application> tag within which you can specify the resources and life time of the application.
Resources impact styling of your application like colors, brushes and visual control (I will write more about this in a later post).
Life time is controlled by defining events fired by the application. A number of events are available and all are already declared within the XAML <Application.ApplicationLifetimeObjects> tag for developers ease.
App.xaml.cs : Application scope events declared in App.xaml file are already captured/wired in this file for you. The implementation of most events however is left blank. If you want to perform an action encompassing the entire application this is where you will write code such as application launch or application deactivation. This is also where you need to handle navigational issues or taking measures against unhandled exceptions.
MainPage.xaml : People having knowledge of ASP .net find this concept simpler to understand. This file provides xaml markup to control user interface of the main phone application page. It is composed of number of UI controls nested and defined as a tag each having its relative properties specified.
MainPage.xaml.cs : This is the code behind file for the main phone application page. Any events exposed by the controls are captured here.
Which Windows Phone 7 Project Template you should begin with?
Nature of the Article: Beginner
You will notice the New Project dialog box allows you to choose between following projects templates types under Silverlight for Windows Phone category,
Though most developers will find reasonable to begin with “Windows Phone 7 Application” type, there is a lot more under Windows Phone 7 canvas. If you are serious to learn and develop at-least one complete windows phone 7 application, you got to try all five of them. Here I have provided quick explanation for each project type,Windows Phone 7 Application
A standard Windows phone 7 application project type that helps building blank one page (MainPage.xaml) screen (off course you can add more if you desire so). The minimal required resources for a blank application (application background image, application cons and startup splash screen) are added so that you can take it from there.
If you are getting started with Phone 7 application development, this is the recommended one that will be your ultimate choice for at-least couple of basic projects.
Windows Phone Databound Application
This type of application provides understanding to navigation (since the template creates two basic pages MainPage.xaml and DetailsPage.xaml with properly hooked navigation) and consumes data in the form of XML. Note that this application type makes use of both design time and runtime data.
In today’s world no application can escape data usage. Once you understand what elements make a basic Windows Phone 7 Application like (previous section), databound application should be your next target type.
Note: The application type is based over MVVM (Model View-ViewModel) design pattern so a basic understanding of this pattern will help you better consume Databound application types. Take a look at this cleanly put article,
http://csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html
Windows Phone Class Library
Just like a standard windows class library, this project template helps you create your own controls or routines that are compiled as “.dll” library which you can further distribute. These dlls reference can be utilized by Windows Phone 7 consumer application.
Windows Phone Panaroma Application
A type of application based over the “Panaroma” control offered by Windows Phone 7 framework classes. As the name suggests, this type of application allows you to create an application which contains multiple pages and provides control on scrolling background (as you pan and flick between pages) using Panaroma control.
Note: If you don’t understand what a Panaroma control is, I would suggest you to take a look at this beautiful article by Stephen,
http://blogs.msdn.com/b/stephanc/archive/2010/04/04/windows-phone-7-panorama-control-sample.aspx
Windows Phone Pivot Application
Similar to above above, this type of application utilizes the Pivot control to simplify creation of application that contains multiple pages. Use this application type to understand how Pivot control look like and behavior of Pivot control for navigation purposes. Normally you will not develop on top of this type of application but rather use the concept of learnt with this application type.
Note: To understand the idea behind Pivot control, follow this post by Stephen,
http://blogs.msdn.com/b/stephanc/archive/2010/05/09/windows-phone-7-pivot-control-sample.aspx
Conclusion
It is recommended to take a look at each template type and learn the concepts presented. Though it is a matter of personal choice, most developers will end up by starting a new blank application type project and will manually add stuff to their convenience taking concepts from each “databound”, “panaroma” and “pivot” type templates.
SQL Server Data-tier Application Properties; Good to have
I was playing with SQL server data-tier application today and I thought of few changes which would make a good addition in properties console,
1- Under Properties > Database.sqlsettings, I think it will be great if a tooltip is provided for each checkbox. Something like this,
2- Under Properties > ServerSelection.sqlpolicy, the dialog box that appears either requires input value or selection from drop down but relatively the notification that appears at the top of dialog box seems unusual,
Personally I find if notification be removed, will make the dialogs appear more elegant



