Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.
Simple WP7 Application using Visual Studio Express
Windows Phone 7.5
Nokia has announced a new device 'Mango' with the first Windows Phone OS. With this announcement, Nokia has opened the door for the developer community to start the work over Windows Phone. Here, in this example, We will see two basic elements; a Textbox and a Button, mostly used while developing any application on Window Phone. The simple demostration shows a textbox and a button, which will show the value of text box as a MessageBox.
What you need?
You need to download and install Windows Phone SDK which is available to download from the Category:Windows Phone. Remember that Windows Phone SDK require Windows Vista or Windows 7 Operating system to install.
Once you install Windows Phone SDK, goto Start->Microsoft Visual Studio 2010 Express->Microsoft Visual Studio 2010 Express->Microsoft Visual Studio 2010 Express for Windows Phone. You will see the application as shown in below figure.
Goto File Menu-> New Project You can see on the left hand side of the dialog box showing the installed templates. You can select Visual Basic or Visual C# to use as your programing language. Here I am selecting Visual C# and "Silverlight for windows phone" under this category. Give the Project Name of your wish. e.g. "MyFirstApplication". Also select location where you wish to save the project. Please refer the following dialog box for the reference.
As soon as you will click on OK button it will ask you "Target Windows Phone version". Select "Windows Phone 7.1" or "Windows Phone 7.0" The following screen gives small idea of the basic screen.
Placing the controls on the layout.
click on Toolbox and place "Textbox" and "Button" controls in the phone layout as shown in the following figure. You can set height and width of both the control as per your wish. Change the property for both the control as follow. You can discover more important preperties also.
|Control||Property to change||Value to set|
On Click event
So far we have placed the controls and set the appropriate properties. Now double click on Button control we just placed on the phone layout. You will see code view where you can write actual code. Place the following code.
private void btnShowValue_Click(object sender, RoutedEventArgs e)
MessageBox.Show("Hello " + txtName.Text);
// MessageBox.Show is used to popup a message box with the text within the brackets. "+" sign is used to
// show string concatenation in C#
// You can use "//" or " /*...........*/ to comment the text
Run the program
As soon as you run the application, You can see the Windows Phone Emulator to test the application. Following screen shows two different states of running above application.
Windows Phone Emulator