This repo contains the samples that demonstrate the API usage patterns and popular features for the Windows Presenation Foundation in the .NET Framework for Desktop. These samples were initially hosted on MSDN, and we are gradually moving all the interesting WPF samples over to GitHub.All the samples have been retargeted to .NET 4.5.2.
For additional WPF samples, see WPF Samples.
Unless otherwise mentioned, the samples are released under the MIT license
Help us improve out samples by sending us a pull-request or opening a GitHub Issue
Questions: mail [email protected]
These samples require Visual Studio 2015 to build, test, and deploy.
Get a free copy of Visual Studio 2015 Community Edition with support for building WPF apps
The easiest way to use these samples without using Git is to download the zip file containing the current version (using the link below or by clicking the "Download ZIP" button on the repo page). You can then unzip the entire archive and use the samples in Visual Studio 2015.
Notes:
- Before you unzip the archive, right-click it, select Properties, and then select Unblock.
- Most samples should work independently
- By default, all the sample target .NET 4.5.2, you can change this to .NET 4.6 in the Project->Properties page in Visual Studio.
For more info about the programming models, platforms, languages, and APIs demonstrated in these samples, please refer to the guidance available in MSDN. These samples are provided as-is in order to indicate or demonstrate the functionality of the programming models and feature APIs for WPF.
##Samples by category
Getting Started | ||||
---|---|---|---|---|
Hello World Sample | Simple Layout | Complex Layout | Dynamic Application | Multipage Application |
WPF Controls Gallery | Sample Gallery |
Element Tree and Serialization | ||||
---|---|---|---|---|
Overriding the Logical Tree | Searching for an Element |
Properties | ||||
---|---|---|---|---|
Custom classes with Dependency Properties | Restoring Default Values | PropertyChanged and CoerceValue Callbacks |
Events | ||||
---|---|---|---|---|
Adding an Event Handler | Custom Routed Events | Finding a Source Element in an Event Handler | ||
Routed Event Handling Sample |
Resources | ||||
---|---|---|---|---|
Application Resources | Defining a Resource | Merged ResourceDictionary |
Styles and Templates | ||||
---|---|---|---|---|
Introduction to Styling and Templating | Event Triggers | Content Control Style | Finding Template-Generated Elements | Alternating the Appearance of Items |
Themes |
Threading | ||||
---|---|---|---|---|
Multithreading Web Browser | Single Threaded Application with Long Running Calculation | Weather Service Simulation with Dispatcher |
Digital Ink | ||||
---|---|---|---|---|
MSDN |
Navigation | ||||
---|---|---|---|---|
MSDN |
Application Extensibility | ||||
---|---|---|---|---|
MSDN |
Clipboard | ||||
---|---|---|---|---|
Clipboard Spy | Clipboard Viewer |
Drag & Drop | ||||
---|---|---|---|---|
Drag and Drop an Object on a Canvas | Create a Data Object from a Text Selection | Drag-and-Drop Events Explorer | Data Formats Spy | Load a Dropped File |
Thumb Drag Functionality |
Graphics | ||||
---|---|---|---|---|
Bitmap Effects | Brushes | Geometries | Imaging | Shapes |
Transformations |
Visual Layer | ||||
---|---|---|---|---|
Using the CompositionTarget | Hit Test Using DrawingVisuals | Hit Test with Win32 Interoperation |
Media | ||||
---|---|---|---|---|
Media Gallery |
Speech | ||||
---|---|---|---|---|
Using Speech |