1.5 WPF
WPF stands for Windows Presentation Foundation. Itβs a UI (User Interface) framework developed by Microsoft for building Windows desktop applications.
1. π‘ What is WPF Used For?
WPF is used to create:
- Rich desktop applications with graphical interfaces
- Applications with modern UI designs (e.g., animations, styles, themes)
- Data-driven apps (like dashboards, form-based apps)
1.1 Key Features
Feature | Description |
---|---|
XAML | Uses XML-based markup to design UI declaratively (.xaml files). |
Data Binding | Connects UI controls to data models (e.g., MVVM pattern). |
Vector Graphics | UI scales smoothly on high-DPI screens. |
Styles and Templates | Customize the appearance of controls. |
Animations | Built-in support for rich UI transitions. |
Hardware Acceleration | Uses DirectX for fast rendering. |
1.2 π Example
XAML (UI layout):
<Window x:Class="MyApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Title="Hello WPF" Height="200" Width="300"> <Grid> <Button Content="Click Me" Width="100" Height="30"/> </Grid></Window>
C# (Code-behind):
public partial class MainWindow : Window{ public MainWindow() { InitializeComponent(); }}
1.3 Technologies it builds on:
- .NET (Framework or Core/5+/6+/7+)
- XAML for UI
- MVVM (Model-View-ViewModel) is the common architecture
1.4 β When to Use WPF
- Youβre building a Windows-only desktop app
- You want a custom, modern UI
- You need data binding, templates, animations, or advanced layout
1.5 β When not to Use WPF
- If youβre building cross-platform apps β use MAUI, Electron, or web apps
- If you only need basic UI β WinForms might be simpler