Windows Presentation Foundation (WPF)
Windows Presentation Foundation (WPF) is a UI framework for building Windows desktop applications with .NET. It combines a powerful markup language (XAML) with a rich set of graphics, animation, and data-binding capabilities.
Key Features
- Declarative UI with XAML – design interfaces using XML‑based markup.
- Data Binding – synchronize UI and business data with minimal code.
- Templates & Styles – fully customize the look of controls.
- Vector‑based Rendering – resolution‑independent graphics.
- Animation & Media – build rich, interactive experiences.
- Hardware Acceleration – leverage DirectX for high‑performance UI.
Simple Hello World
Below is a minimal WPF application that shows a window with a button. Click the button to display a message.
<Window x:Class="HelloWorld.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Hello World" Height="200" Width="300">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Content="Click Me" Width="100" Click="OnClick"/>
</StackPanel>
</Window>
using System.Windows;
namespace HelloWorld
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void OnClick(object sender, RoutedEventArgs e)
{
MessageBox.Show("Hello, WPF!");
}
}
}