UWP Development, Text

Hello! In this post, we will take a closer look at UWP (Universal Windows Platform) development. UWP development is a platform that allows developers to create apps that work across a variety of Windows devices. The ability to create apps that run smoothly on Windows 10 and later devices presents an attractive opportunity for developers.

What is UWP?

UWP is a new model for apps that run on the Windows operating system, creating a single codebase that can run on various devices. UWP is a core element of Windows 10, enabling the same app to be used across mobile, PC, Xbox, IoT devices, and more.

Basic Concepts of UWP

  • Single Codebase: UWP apps provide a single codebase that can run on various devices.
  • UI and UX: Supports flexible UI/UX design that adapts to different screen sizes and resolutions.
  • API Access: Allows access to WinRT APIs to leverage system features for powerful apps.

Setting Up the UWP Development Environment

To develop UWP apps, you must meet a few requirements:

  • Windows 10 SDK: You need to install the latest Windows 10 SDK, which installs with Visual Studio.
  • Visual Studio: You need Visual Studio 2019 or later, which supports UWP desktop application development.

Installing Visual Studio

Here’s how to install Visual Studio:

  1. Visit the official Visual Studio website and download the installation file.
  2. Run the downloaded installation file and select the components to install.
  3. Select “Desktop development with .NET” to install the necessary components for UWP development.
  4. After installation, launch Visual Studio.

Creating Your First UWP App

Now, let’s create a basic UWP app. UWP apps use XAML (Extensible Application Markup Language) UI composed of various elements.

Creating a Project

  1. Launch Visual Studio and select “Create New” > “Project”.
  2. Search for and select “UWP App”.
  3. Specify the project name and location, then click “Create”.
  4. Set the default configuration and click “Create”.

Writing Code

Once the project is created, you can open the MainPage.xaml file to add UI elements. The basic code looks like this:

<Page
    x:Class="MyFirstUWPApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyFirstUWPApp"
    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}">
        <TextBlock Text="Hello, UWP!"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   FontSize="32"
                   Foreground="Black"/>
    </Grid>
</Page>

Running the App

To run the app, press “Ctrl + F5” to run without debugging or “F5” to run in debug mode. As a result, you will see a simple app with the message “Hello, UWP!” displayed in the center.

Main Features of UWP Apps

UWP apps support various features, some of which include:

Live Tiles

UWP apps offer live tile functionality that can be used with the Windows start menu, providing users with real-time information or showing different functionalities of the app.

Push Notifications

Through Push Notification services, users can receive information even if they do not launch the app. These services help improve user interaction.

Responsive Layouts

UWP provides responsive UI layouts that adapt automatically to various resolutions and screen sizes, ensuring an optimal user experience on phones, tablets, PCs, and more.

Handling Data in UWP

Data handling is a crucial aspect of UWP apps. Storing and loading data can be handled in various ways, with the most common methods being the use of “LocalSettings” and “File” APIs.

Using LocalSettings

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
localSettings.Values["UserName"] = "John Doe";

Using the File API

StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile sampleFile = await storageFolder.CreateFileAsync("sample.txt", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(sampleFile, "Hello, UWP File!");

Distribution Methods for UWP

After developing the app, you need to distribute it. UWP app distribution is done through the Microsoft Store, and the following steps should be followed:

  1. Create an app package: After building the app in Visual Studio, you need to create a package for distribution.
  2. Register with Microsoft Partner Center: You need to register with Microsoft Partner Center to distribute the app.
  3. Submit and verify messages: After submitting the app, it will be reviewed by Microsoft, and based on the review results, the app can be distributed in the Microsoft Store.

Conclusion

UWP development offers an exciting opportunity to develop diverse apps within the Windows ecosystem. In this post, we briefly introduced the basic concepts of UWP, app development, and distribution methods. Apply various APIs and UI designs to create your own amazing UWP apps!