Create Your First Universal Windows App

Before starting you should have Windows 10 and Visual Studio 2015 installed on your systems. Now, let’s get started.

  1. First open visual studio and create a new project.

    create a new project

    Great, you have created your first project. Now lets go and see about that "Hello World."

  2. In the solution explorer look for the MainPage.xaml and open it.

    MainPage.xaml

    This is the XAML file where you can add the tools you want in your app. You can either do this by using the XAML file or by dragging and dropping the tools from toolbox to the designer view. This is your default main page that will appear when you run the application, I'll tell you in another post on how to change the default main page. For the sake of this post I'm just going to drag and drop the tools, but just know that it is not a good practice.

  3. Now let's start adding the tools. Search for TextBlock in the Toolbox, it should be in the Common XAML Controls, click on it and drag and drop it in your phone in the designer view. TextBlock is just like a Label we have in Windows Form. Next search for the Button tool and also drag and drop it on the screen. You can also press Enter after selecting the tool from toolbox and it will appear on the screen in the designer view. See that after adding these tools in the designer their tags are also added in the xaml file. You can change your Button and TextBlock's properties in this file too.

    TextBlock

  4. The next thing we want to do is to change the fontsizes of both the tools that we have just added. Click on the tool go to the Properties Windows, there find the category 'Text' and from there you can change the fontsize.

    fontsize

    Now go ahead and delete the text that is written in the TextBlock and change the text of Button to "Click Me!". For TextBlock you can find the Text property in the Common category and for Button the Content property in the Common category.

    Text property

    property

  5. Now we have to add a 'Click' event for the button. For this click on the button, go to the properties windows and look for the lightening shaped icon and click on it.

    Click

    You will see a Click event, go ahead and double click on the textbox in front of it. This will lead you to code behind .cs file of this page. Just copy and paste the code below in the event:

    Code

  6. Now go and run your app and click on the button and you can see the "Hello World." written on the textblock.

Congratulations!. You have just created your first Universal Windows app.

Read more articles on Universal Windows Apps:


Similar Articles