Overview
The Universal Windows Platform (UWP) provides a rich set of UI controls and layout panels that enable developers to create adaptive, modern experiences across all Windows 10 devices.
Namespaces
Windows.UI.XamlWindows.UI.Xaml.ControlsWindows.UI.Xaml.MediaWindows.UI.Xaml.InputWindows.UI.Xaml.Automation
Key Classes
| Class | Description |
|---|---|
Button | Standard clickable button. |
TextBox | Editable text input. |
Grid | Flexible 2‑D layout container. |
StackPanel | Linear layout (vertical/horizontal). |
ListView | Scrollable list of items with selection. |
Common Controls
Button
CheckBox
RadioButton
ComboBox
Slider
Layout System
UWP offers several layout panels to arrange UI elements responsively:
- Grid – rows and columns.
- RelativePanel – position relative to other elements.
- StackPanel – linear stacking.
- Canvas – absolute positioning.
Styling & Themes
Control appearance is driven by ResourceDictionary objects and system themes (Light/Dark). Use ThemeResources to reference system colors.
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Click me" Style="{StaticResource PrimaryButtonStyle}" />
</Grid>
</Page>
Sample Code
Below is a minimal UWP page that demonstrates a button with a click handler.
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
MyButton.Click += OnButtonClick;
}
private void OnButtonClick(object sender, RoutedEventArgs e)
{
ResultText.Text = "Button clicked!";
}
}
XAML markup:
<Page
x:Class="SampleApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Padding="24">
<Button x:Name="MyButton" Content="Press me" Width="200" />
<TextBlock x:Name="ResultText" Margin="0,12,0,0" FontSize="16"/>
</StackPanel>
</Page>