UWP (Universal Windows Platform) app development is a powerful way to create applications that can run on various Windows 10 devices. In this article, we will start from the basics of UWP development and explain in detail how to install the apps you have developed on actual devices.
What is UWP?
UWP is a platform developed by Microsoft that is designed to create apps that run on various Windows 10 devices (PCs, tablets, Xbox, IoT devices, etc.) from a single code base. The main advantage of UWP is that it allows for a unified user experience across different devices. This particularly provides app developers with the opportunity to reach a wider audience.
Features of UWP
- Responsive Design: Supports various screen sizes to provide the best user experience on all devices.
- Modular Size: Apps are composed of small modules, allowing for the installation of only the necessary functions.
- Security and Sandbox: UWP apps run in a sandboxed environment, limiting access to system resources.
- Storage Access: Securely access the file system using the Windows Storage API.
Preparing for UWP App Development
To develop a UWP app, some preliminary preparations are needed. Follow the steps below for guidance.
Installing Required Tools
- Install Visual Studio: Visual Studio is required for UWP app development. The Visual Studio Community version is available for free and includes all necessary tools.
- Windows 10 SDK: The Windows 10 SDK is needed for UWP development. It is included automatically when installing Visual Studio.
Creating a Project
- Run Visual Studio and click on ‘Create a New Project.’
- In the template list, navigate to ‘Windows’ > ‘UWP’ category.
- Select the ‘Blank App (App Name)’ template and click ‘Next.’
- Choose the project name and save location, then click the ‘Create’ button.
Creating a Simple UWP App
Now let’s create a simple UWP app. This app will have the feature of changing the text when a button is clicked.
Writing XAML Code
Once the project is created, open the MainPage.xaml file. Write the XAML code as follows:
<Page
x:Class="MyUwpApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyUwpApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button x:Name="myButton" Content="Click Here" HorizontalAlignment="Center" VerticalAlignment="Center" Click="myButton_Click"/>
<TextBlock x:Name="myTextBlock" Text="Text will appear here." HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,50"/>
</Grid>
</Page>
Writing Code Behind
Now modify the MainPage.xaml.cs file to handle the button click event. Add the following code:
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace MyUwpApp
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void myButton_Click(object sender, RoutedEventArgs e)
{
myTextBlock.Text = "Button has been clicked!";
}
}
}
Running the App
After writing the code, click on ‘Debug’ > ‘Start Debugging’ in the top menu of Visual Studio to run the app.
Installing UWP Apps
Now we are ready to install and deploy the simple app. There are several methods to install UWP apps, and we will look at a few key methods in this section.
Installing the App on Local Machine
To install the app you are developing on your local machine, follow these steps:
- Click on ‘Debug’ > ‘Start Debugging’ in Visual Studio. This method allows you to run the app directly.
- To install the packaged app, select ‘Build’ > ‘Build Solution’ to build the app.
- Find and enter the ‘Package’ folder in the Solution Explorer.
- Once the package for the UWP app is created, find the package and double click to install it.
Distributing to Microsoft Store
To distribute the app, you can publish it through the Microsoft Store. To do this, follow these steps:
- Sign up for the Microsoft Dev Center. You can choose a personal developer account or a business account.
- Prepare to package the app and select ‘App Distribution’ in the ‘Package’ menu.
- Enter the required information and upload the app package.
- After store review and approval, users will be able to install the app.
Conclusion on Installing UWP Apps
We have reviewed the basics of UWP app development and installation. The UWP platform enables powerful and flexible app development and can provide a seamless user experience on Windows 10 devices. Develop more UWP apps based on your creative ideas!