Windows10 Development Tutorial
Windows10 Development Tutorial
Audience
This tutorial has been prepared for anyone who has a basic knowledge of XAML, C#, and
Visual Studio and has an urge to develop apps for mobile or desktop.
Prerequisites
Before you start proceeding with this tutorial, we are assuming that you have a good
understanding of the basics of XAML, C#, and Visual Studio. If you are not well aware of
these concepts, then we will suggest you to go through our short tutorials on these
topics.
All the content and graphics published in this e-book are the property of Tutorials Point
(I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or
republish any contents or a part of contents of this e-book in any manner without written
consent of the publisher.
We strive to update the contents of our website and tutorials as timely and as precisely
as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I)
Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of
our website or its contents including this tutorial. If you discover any errors on our
website or in this tutorial, please notify us at contact@tutorialspoint.com
i
Windows 10 Apps Development
Table of Contents
About the Tutorial ............................................................................................. i
Audience .......................................................................................................... i
Prerequisites..................................................................................................... i
Copyright & Disclaimer ...................................................................................... i
Table of Contents ............................................................................................. ii
1. Introduction .................................................................................................. 1
Universal Windows app ..................................................................................... 1
Characteristics of UWP apps .............................................................................. 2
Development Choices ....................................................................................... 2
9. Adaptive UI ................................................................................................. 50
VisualStateManager ........................................................................................ 50
RelativePanel ................................................................................................. 52
ii
Windows 10 Apps Development
iii
Windows 10 Apps Development
1. Introduction
This tutorial is designed for people who want to learn how to develop Windows 10
applications. In this tutorial, we are going to learn -
A lot of interesting app scenarios are now possible that were not available to us in the
first release. Microsoft has not only added new APIs, they have also extended the
existing APIs.
Now, in Windows 10, the name of the Universal Application Platform has been changed
to Universal Windows Platform (UWP). You can build modern and fully immersive apps
by targeting Windows 10 devices for Windows Store such as PC, tablet, phone, etc.
In Windows 10, you can easily develop applications to reach all the devices supported on
Windows 10 with just –
The Universal Windows Platform also supports different screen sizes and different
interaction models such as touch pad, mouse & keyboard, a game controller, or a pen.
1
Windows 10 Apps Development
You can target device families and not OS like Windows 8.1.
Apps are packaged and distributed using the .AppX packaging format, which
ensures that your apps can be deployed and updated seamlessly.
You can submit your application to the Windows store and it will make it available
on all device families, or only those devices you choose. You can easily manage all
your apps for Windows devices in one place.
You can limit the availability of your application to the particular device family.
The core APIs of Universal Windows Platform (UWP) are the same across all
Windows device families. So your app can run on all Windows 10 devices if it is
uses only the core APIs.
With the help of Extension SDKs, you can light up your application for particular
devices.
Development Choices
Universal Windows applications can be created in any of the following languages:
You can also write components in one language and use them in an application that is
developed in another language.
2
Windows 10 Apps Development
2. Windows 10 – UWP
WinRT APIs provide access to all core platform features using JavaScript, C#, Visual
Basic, and C++.
WinRT components support multiple languages and APIs such as native, managed
and scripting languages.
In Windows 8.1, WinRT, for the first time, was aligned between Windows Phone 8.1
applications and Windows 8.1 applications with the help of Universal Windows 8
apps to target both Windows phone and Windows application using a shared
codebase.
Windows 10 Unified Core, which is known as Windows Core now, has reached to a
point where UWP, now, provides a common app platform available on every device
that runs on Windows 10.
3
Windows 10 Apps Development
UWP not only can call the WinRT APIs that are common to all devices, but also APIs
(including Win32 and .NET APIs) that are specific to the device family that the app
is running on.
Device families have their own APIs as well, which add functionality for that particular
device family. You can easily determine all the devices, within a device family, on which
your applications can be installed and run from the Windows Store. Here is the
hierarchical representation of the device family.
Advantages of UWP
Universal Windows Platform (UWP) provides a handful of things for developers. They
are:
One Operating System and One Unified Core for all the devices.
One App Platform to run the applications across every family.
One Dev Center to submit application and dashboard.
One Store for all the devices.
4
Windows 10 Apps Development
1. Windows 10 OS: UWP apps need the latest version of Windows to develop. You
can also develop UWP applications on Windows 8.1 but there is no support for UI
designer Window.
2. Windows 10 developer tools: In Visual studio 2015, you can design, code, test,
and debug your UWP apps. You can download and install the free Microsoft Visual
Studio Community 2015 from https://dev.windows.com/en-us/downloads
3. Enable development mode for Windows 10:
Go to Start > Settings.
Select Update & security.
Then select “For developers”.
Click on the Developer mode.
4. Register as an app developer: You can start developing apps, but to submit your
apps to the store, you need a developer account. You can create your developer
account here https://msdn.microsoft.com/en-
us/library/windows/apps/bg124287.aspx
5
Windows 10 Apps Development
After following the above steps, you are now ready to start the development of a
Universal Windows Platform (UWP) application.
6
Windows 10 Apps Development
3. Windows 10 – First App
In this chapter, we will be creating our first simple application “Hello world” in
Universal Windows Platform (UWP) using XAML and C# on Windows 10. We will
demonstrate how a single UWP application created in Visual Studio can be run and
executed on any Windows 10 device.
Let us start creating the App by following the steps given below.
7
Windows 10 Apps Development
3. The following New Project dialog window will be displayed. You can see the
different types of templates on the left pane of the dialog box.
4. In the left pane, you can see the tree view. Select Universal template from
Templates > Visual C# > Windows.
5. From the center pane, select the Blank App (Universal Windows) template.
8
Windows 10 Apps Development
8. You can see the newly created project in the Solution Explorer.
9. This is a blank app but it contains many files, which is the minimum requirement
for any UWP application.
10. MainPage.xaml and MainPage.xaml.cs run when you execute your application.
<Page
x:Class=”UWPHellowWorld.MainPage”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:local=”using:UWPHellowWorld”
xmlns:d=”http://schemas.microsoft.com/expression/blend/2008”
xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006”
mc:Ignorable=”d”>
9
Windows 10 Apps Development
</Grid>
</Page>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace UWPHellowWorld
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
}
}
10
Windows 10 Apps Development
13. Let us add some Text Blocks, a textbox, and a button as shown in the XAML code
below.
<Page
x:Class=”UWPHellowWorld.MainPage”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:local=”using:UWPHellowWorld”
xmlns:d=”http://schemas.microsoft.com/expression/blend/2008”
xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006”
mc:Ignorable=”d”>
<StackPanel HorizontalAlignment=”Center”>
<TextBlock Text=”Hello, world!”
Margin=”20”
Width=”200”
HorizontalAlignment=”Left”/>
<TextBlock Text=”Write your name.”
Margin=”20”
Width=”200”
HorizontalAlignment=”Left”/>
<TextBox x:Name=”txtbox”
Width=”280”
Margin=”20”
HorizontalAlignment=”Left”/>
<Button x:Name=”button” Content=”Click Me”
Margin=”20”
Click=”button_Click”/>
<TextBlock x:Name=”txtblock”
HorizontalAlignment=”Left”
Margin=”20”/>
</StackPanel>
</Grid>
</Page>
11
Windows 10 Apps Development
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace UWPHellowWorld
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
12
Windows 10 Apps Development
15. In the UWP project, device preview option is available on the Design Window,
with the help of which you can change the layout easily, to fit into the screen size
of all the devices in a device family you are targeting for your application.
13
Windows 10 Apps Development
16. You can run and test your app either on a local machine, a simulator or an emulator,
or on a remote device. You can select the target device from the following menu
as shown below:
17. Let us run the above code on a local machine and you will see the following window.
Now, write any name in the text box and click the button Click Me.
14
Windows 10 Apps Development
18. Now, if you want to test your app on an emulator, you can select a particular
emulator from the menu and execute your application. You will see the following
emulator:
15
Windows 10 Apps Development
4. Windows 10 – Store
The benefit of Windows Store for developers is that you can sell your application. You
can submit your single application for every device family.
The Windows 10 Store is where applications are submitted, so that a user can find
your application.
In Windows 8, the Store was limited to application only and Microsoft provides
many stores i.e. Xbox Music Store, Xbox Game Store etc.
In Windows 8, all these were different stores but in Windows 10, it is called
Windows Store. It is designed in a way where users can find a full range of apps,
games, songs, movies, software and services in one place for all Windows 10
devices.
16
Windows 10 Apps Development
Monetization
Monetization means selling your app across desktop, mobile, tablets and other devices.
There are various ways that you can sell your applications and services on Windows
Store to earn some money.
The simplest way is to submit your app on store with paid download options.
The Trails option, where users can try your application before buying it with limited
functionality.
Add advertisements to your apps with Microsoft Advertising.
Microsoft Advertising
When you add Ads to your application and a user clicks on that particular Ad, then the
advertiser will pay you the money. Microsoft Advertising allows developers to receive Ads
from Microsoft Advertising Network.
The Microsoft Advertising SDK for Universal Windows apps is included in the
libraries installed by Visual Studio 2015.
You can also install it from
https://visualstudiogallery.msdn.microsoft.com/401703a0-263e-4949-8f0f-
738305d6ef4b
Now, you can easily integrate video and banner Ads into your apps.
Let us have a look at a simple example in XAML, to add a banner Ad in your application
using AdControl.
1. Create a new Universal Windows blank app project with the name UWPBannerAd.
17
Windows 10 Apps Development
3. Select Add References, which will open the Reference Manager dialog.
4. From the left pane, select Extensions under Universal Windows option and check
the Microsoft Advertising SDK for XAML.
18
Windows 10 Apps Development
5. Click OK to Continue.
6. Given below is the XAML code in which AdControl is added with some properties.
<Page
x:Class="UWPBannerAd.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWPBannerAd"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UI="using:Microsoft.Advertising.WinRT.UI"
mc:Ignorable="d">
19
Windows 10 Apps Development
Width="800"/>
</StackPanel>
</Grid>
</Page>
When the above code is compiled and executed on a local machine, you will see the
following window with MSN banner on it. When you click this banner, it will open the
MSN site.
You can also add a video banner in your application. Let us consider another example
in which when the Show ad button is clicked, it will play the video advertisement of
Xbox One.
Given below is the XAML code in which we demonstrate how a button is added with some
properties and events.
<Page
x:Class="UWPBannerAd.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWPBannerAd"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UI="using:Microsoft.Advertising.WinRT.UI"
mc:Ignorable="d">
20
Windows 10 Apps Development
</Grid>
</Page>
using Microsoft.Advertising.WinRT.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace UWPBannerAd
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
InterstitialAd videoAd = new InterstitialAd();
public MainPage()
{
this.InitializeComponent();
}
videoAd.AdReady += videoAd_AdReady;
videoAd.RequestAd(AdType.Video, MyAppId, MyAdUnitId);
}
21
Windows 10 Apps Development
videoAd.Show();
}
}
}
}
When the above code is compiled and executed on a local machine, you will see the
following window, which contains a Show Ad button.
22
Windows 10 Apps Development
Now, when you click on the Show Ad button, it will play the video on your app.
23
Windows 10 Apps Development
5. Windows 10 – XAML Controls
24
Windows 10 Apps Development
Layout Controls
Layout of Controls is very important and critical for application usability. It is used to
arrange a group of GUI elements in your application. There are certain important things
to consider while selecting the layout panels:
Controls Description
SplitView represents a container with two views; one view for the
SplitView
main content and another view that is typically used for navigation
commands.
RelativePanel defines an area within which you can position and
RelativePanel
align child objects in relation to each other or the parent panel.
25
Windows 10 Apps Development
26
Windows 10 Apps Development
27