Universal Windows Platform (UWP) APIs
Explore the core APIs that power Universal Windows Platform applications. UWP allows developers to build apps that can run across all Windows 10 and Windows 11 devices, from Xbox and HoloLens to PCs and tablets, with a single codebase.
Getting Started with UWP Development
Learn the fundamentals of UWP development, including project setup, XAML for UI, and the core concepts of the platform.
Core UWP API Categories
Dive into specific API areas that are essential for building modern UWP applications:
- Windows.UI.Xaml: The primary namespace for UI elements, controls, and layout management.
- Windows.UI.Core: Provides access to core UI concepts like input handling, focus, and dispatching.
- Windows.Foundation: Contains fundamental types and interfaces used throughout the UWP.
- Windows.Storage: APIs for accessing and managing files and folders.
- Windows.Networking: Classes for network communication, including TCP, UDP, and HTTP.
- Windows.ApplicationModel: APIs related to application lifecycle, package management, and system services.
- Windows.UI.Popups: APIs for displaying dialogs, message boxes, and content dialogs.
Example: Handling Button Clicks in XAML
A simple example demonstrating how to define a button in XAML and handle its click event in C#:
// MainPage.xaml
<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"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Button Content="Click Me" Click="MyButton_Click" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Page>
// MainPage.xaml.cs
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)
{
// TODO: Implement button click logic
var button = sender as Button;
if (button != null)
{
button.Content = "Clicked!";
}
}
}
}