Tuesday, May 24, 2016

Lesson 1: Windows Mobile APP Development

  
  To develop windows mobile application, you need Windows 8.1 or higher version of operating system(usually 64 bit) installed in your system. Install Microsoft Visual studio 2013 with sdk. Remember  you should use only 64 bit operating system as sdk is supported by only 64 bit OS. Your computer should have at least 4GB RAM in it. For smaller static APPs you do not require any database software installed in your system. I will let you know as and when it is required.

How to create a Windows Phone APP?

open visual studio. Select new project from the Menu and select Windows Phone APP from the given options. Refer figure below. Select Visual C# in the left panel.(i.e. you are going to write the code using C# language.).
You can set the name and location of your project here. 



once you are done with the above steps. press ok to get a new window which contains a phone-like structure (Emulator) and few other stuff. The mobile like window which appears in the middle of the window is called emulator which has all the functionalities that a physical mobile do have.


In the above image, the black screen is the main page where you are going to do the design of your APP. The left hand side list is called toolbox where all the controls are present and these controls can be dragged on to the Main page.

The code that appear to the immediate right of the black screen is XAML code which is automatically generated for the main page. i.e. whatever changes are made to the black screen will be reflected in the XAML code and vice-versa.

The right hand side windows is called as solution explorer which handles other important stuffs like properties, assets, project names , folders etc.

By default, the main page has two parts. The first upper part contains the name of the application which can be changed in the properties.

The other part is to hold other controls like textbox, textblock, button, listbox, slider etc..

Let's start with a very simple application. This application contains only one button. When you click on the button, a message is displayed.

To do this , drag a button onto the workspace. name it accordingly in the properties. You can change the content property of the button (in this example the content property is set as "Click me to say hello").




When you drag the button to the workspace, the following  XAML code gets generated automatically.

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
 <Button x:Name="btnHello" Content="Click Me to Say Hello " HorizontalAlignment="Left" Height="163" Margin="95,135,0,0" VerticalAlignment="Top" Width="273" Click="btnHello_Click"/>
</Grid>

Now, its time to write some code in the button click event. Double click on the button and write the following code in the button_click event.

private void btnHello_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Hello");
        }

Now, save your project using Ctrl+s.
Run your project by clicking on start button on the menu bar. (or press ctrl+F5)
You will get a phone_like structure on your screen where you will find a button. 
Click on the button to get the desired result.


Enjoy programming.

1 comment: