WPF API Documentation

This documentation provides an overview of the core APIs for Windows Presentation Foundation (WPF). WPF is a powerful UI framework for building Windows desktop applications. It offers a rich set of features for creating visually stunning and highly interactive user experiences.

Namespace: System

The fundamental building blocks of .NET applications.

DependencyObject

The base class for most WPF objects that support the WPF property system. This is the foundation for many WPF features, including data binding, styling, and animation.

public class DependencyObject : object

Key Features:

Namespace: System.Windows

Contains fundamental types and classes used throughout WPF.

Visual

The base class for all WPF objects that can be rendered. It provides the drawing context and supports the visual tree.

public abstract class Visual : DependencyObject

Key Features:

Namespace: System.Windows.Controls

Contains the core UI controls and elements used to build user interfaces.

Control

The base class for all Windows Presentation Foundation (WPF) controls. It provides the basic functionality for controls, such as default template, focus handling, and keyboard navigation.

public class Control : ContentControl

Key Features:

Button

Represents a clickable button control.

public class Button : ButtonBase

Events:

Common Properties:

TextBlock

Displays a block of text. It supports basic text formatting and inline elements.

public class TextBlock : TextElement

Common Properties:

Grid

A flexible layout panel that arranges elements in rows and columns.

public class Grid : Panel

Common Properties:

Usage:

<Grid RowDefinitions="Auto,*" ColumnDefinitions="*,Auto">
    <!-- Row 0, Column 0 -->
    <TextBlock Grid.Row="0" Grid.Column="0" Text="Header"/>
    <!-- Row 1, Column 1 -->
    <TextBlock Grid.Row="1" Grid.Column="1" Text="Content"/>
</Grid>

Namespace: System.Windows.Input

Provides types for handling input, commands, and gestures.

Key

An enumeration that specifies keyboard keys. Used in keyboard event arguments.

public enum Key

Common Values:

MouseButton

An enumeration that specifies mouse buttons. Used in mouse event arguments.

public enum MouseButton

Common Values:

Namespace: System.Windows.Media

Contains types for graphics, multimedia, and visual elements.

Brush

The abstract base class for all brush types used to paint shapes, backgrounds, and text.

public abstract class Brush : Freezable

SolidColorBrush

A brush that paints an area with a solid color.

public class SolidColorBrush : Brush

Constructor:

public SolidColorBrush(Color color)

Common Properties:

Usage:

<TextBlock Text="Hello WPF" Foreground="Blue"/>
<!-- Equivalent C# -->
<TextBlock Text="Hello WPF" Foreground="{StaticResource BlueBrush}"/>
<!-- Resource Dictionary -->
<SolidColorBrush x:Key="BlueBrush" Color="Blue"/>

Key Concepts

Dependency Properties

A property system that extends the standard .NET property system. Dependency properties support features like data binding, styling, animation, and property value inheritance. They are declared using DependencyProperty objects and registered with the WPF property system.

Routed Events

An event handling system that allows events to traverse the element tree. Events can be routed either directly, bubbling up from child to parent, or tunneling down from parent to child. This enables a single event handler to manage an event for multiple elements.

Data Templates

Used to define the visual structure of data. DataTemplates allow you to specify how data objects should be represented in the UI, enabling flexible data binding and customization of control presentation.

Back to Top