Introduction:
In this article we are going to see how to create a Silverlight Windows Phone 7 Application using the Visual Studio IDE. In our earlier article we have seen the software and the hardware requirement in order to start develop a windows phone application. Here in this article we will create a Hello World Application and try to run it in the Windows Phone 7 Emulator to check the working model of the application. Let us jump start to see the step by step process on how to design the application using the Visual Studio 2010 IDE. [more]
Steps:
As we discussed in our earlier article, after installing the Windows Phone 7 SDK, we can see the new template options available with the Visual Studio 2010. The new templates are one for creating Silverlight for Windows Phone Application and other one is for XNA Game Studio 4.0 which will help us to develop respective applications as per the requirement as shown in the screen below.
In this series we are going to concentrate more on the Silverlight for Windows Phone application development for the enterprise and commercial application builders. Also we will see how to create a XNA Game studio application as well so that it will give some idea on the difference between selecting the appropriate project. Let us create a Silverlight for Windows Phone 7 Hello world application, to start with first select the Windows Phone Application and provide the decent name to the project as shown in the screen below.
Clicking on OK will create the application, we can see a popup window asking to select the version of the Windows Phone 7 OS. We will go with selecting the latest platform, Windows Phone OS 7.1 as shown in the screen below.
Clicking on OK will open the project in Visual Studio 2010 IDE, we can see the windows phone 7 interface designer view and the XAML code view as shown in the screen below.
Now drag and drop the controls from the toolbox to get some user input and show output Hello World. Also alternatively we can write the XAML code to get the controls based on the requirement. Once we have the controls on to the designer our screen looks like below.
The XAML code for the above design is given in the below code block to get fair idea on the type of control used and the properties assigned for each control to get a better user interface. Just we can copy and paste this below XAML code on to any Windows Phone 7 Page to get this design. Here we have added 4 Text block, 2 text box for inputs and a button control to trigger some event. Also if you have noticed we have the header with message F5DEBUG APPLICATION in upper case which is the standard we should consider while developing our application.
XAML Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Now we are done with the design, now go to the code behind Submit button Event and write the below code which get the user input from the 2 text boxes (First Name and Last Name ) to provide a welcome message to the user as shown in the code behind.
C# Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Now build the application and execute the project to check the output by pressing F5 from the keyboard directly or by pressing the play button from the IDE tool bar and we can see the output in the Windows Phone 7 Emulator as shown in the screen below.
Note – We need to check if the target to run the application is pointed to Windows Phone Emulator and not Windows Phone Device.
Now we can enter the test inputs and click on Submit button to get the welcome message as shown in the screen below.
Conclusion:
So in this article we have seen how to create a Hello world application in Windows Phone 7 application for Silverlight and we also seen how to use the controls with the designer.
No Comments
really very good and helpful article