MSDN Documentation

WPF UI APIs

This page provides an overview of the core Windows Presentation Foundation (WPF) APIs related to user interface elements, controls, layout, and presentation.

Key Namespaces

System.Windows.Controls

This namespace is central to WPF development, housing a rich collection of pre-built UI elements that can be used to construct application interfaces.

Common Controls:

Items Controls:

These controls are designed to display collections of data.

System.Windows.Layout

Layout management is crucial for responsive and well-organized user interfaces. These classes control how elements are positioned and sized.

System.Windows.Media

This namespace provides the foundation for graphics, drawing, visual effects, transformations, and more.

System.Windows.Shapes

Defines a set of basic geometric shapes that can be used as controls or visual elements.

System.Windows.Input

Handles user input such as mouse clicks, keyboard presses, and touch events.

Example Usage: Creating a Button with TextBlock

This XAML demonstrates how to define a simple button with text content.

<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center">
    <Button.ToolTip>
        <TextBlock Text="This is a tooltip!"></TextBlock>
    </Button.ToolTip>
</Button>

Example Usage: Arranging Controls in a Grid

This XAML shows how to use a Grid layout panel to arrange elements.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="100"/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>

    <TextBlock Text="Name:" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="5"/>
    <TextBox Grid.Row="0" Grid.Column="1" Margin="5"/>

    <Button Content="Submit" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="10"/>
</Grid>