MSDN Community

Your hub for Microsoft developer resources and discussions

Getting Started with Windows Universal Platform (UWP) Development

Welcome to the exciting world of Universal Windows Platform (UWP) development! UWP empowers you to build beautiful, modern applications that run across a wide range of Windows devices, from desktops and laptops to tablets and Xbox.

Note: UWP development is an evolving area. Ensure you are using the latest stable versions of Visual Studio and the Windows SDK for the best experience.

1. Prerequisites

Before you begin, make sure you have the following:

  • Windows 10 or Windows 11: UWP apps are designed for these operating systems.
  • Visual Studio: The latest version of Visual Studio Community (free), Professional, or Enterprise is recommended.
  • Windows Universal Development Tools: During Visual Studio installation, select the "Universal Windows Platform development" workload. This includes the necessary SDKs and components.

2. Setting Up Your Development Environment

Follow these steps to get your environment ready:

1

Install Visual Studio: If you haven't already, download and install Visual Studio from the official Visual Studio website.

2

Select UWP Workload: During the Visual Studio installation or by modifying an existing installation, ensure the "Universal Windows Platform development" workload is checked. This will install the latest Windows SDKs.

3

Update SDKs: You can manage your installed Windows SDKs through Visual Studio Installer. It's good practice to keep them updated.

3. Creating Your First UWP App

Let's create a simple "Hello, World!" UWP application.

1

Launch Visual Studio: Open Visual Studio.

2

Create a New Project: Click "Create a new project".

3

Select UWP Template: In the project templates search bar, type "Blank App (Universal Windows)". Select it and click "Next".

4

Configure Project: Give your project a name (e.g., "MyFirstUWPApp") and choose a location. Click "Create".

5

Choose Target Versions: You'll be prompted to select the Minimum and Target version for your UWP app. For simplicity, you can choose the defaults or select a recent SDK version.

Tip: The Minimum version determines the oldest Windows version your app will run on, while the Target version indicates the version you've primarily tested with.

4. Exploring the Project Structure

Once the project is created, you'll see several files and folders. Key ones include:

  • App.xaml / App.xaml.cs: The entry point for your application.
  • MainPage.xaml: The XAML markup for your app's main user interface.
  • MainPage.xaml.cs: The code-behind file for MainPage.xaml, containing C# logic.
  • Package.appxmanifest: The manifest file containing metadata about your app, its capabilities, and resources.

5. Running Your App

To run your "Hello, World!" app:

  1. In the Visual Studio toolbar, ensure the target device is set to "Local Machine" or "Emulator".
  2. Click the "Start" button (the green triangle) or press F5.

Your application will build and launch, displaying a blank window. For a "Hello, World!" message, you would typically add a TextBlock element to MainPage.xaml:

<TextBlock Text="Hello, World!" HorizontalAlignment="Center" VerticalAlignment="Center" />

6. Next Steps

Congratulations on building your first UWP app! Here are some areas to explore next:

  • XAML Fundamentals: Learn about XAML for UI design, layout panels, controls, and data binding.
  • C# and .NET: Understand how to write code to handle user interactions, manage data, and implement app logic.
  • UI Controls: Familiarize yourself with the rich set of UWP controls like Button, TextBox, ListView, and NavigationView.
  • Visual Studio Designer: Use the visual designer to quickly build and modify your UWP UI.
  • UWP Design Guidelines: Learn how to create intuitive and visually appealing user experiences that are consistent with the Windows design language.
  • Device Capabilities: Explore how to access device features like the camera, microphone, location, and more.
Important: Keep your Visual Studio and Windows SDKs up-to-date to benefit from the latest features, performance improvements, and security patches.

Dive into the official Microsoft documentation and explore the vast ecosystem of UWP development. Happy coding!