+0
日增长
5,747
stars
3,277
forks
321
watchers
464
prs
352
issues
55
releases
README
WPF-Samples
This repo contains the samples that demonstrate the API usage patterns and popular features for the Windows Presentation Foundation in the .NET for Desktop. These samples were initially hosted on MSDN \( https://msdn.microsoft.com/ \), and we are gradually
moving all the interesting WPF samples over to GitHub. All the samples have been retargeted to .NET 10.0.
You can also find an archive of samples targeting .NET 4.7.2 in the netframework branch.
The samples in this repo are generally about illustrating specific concepts and may go against accessibility best practices. However, the team has spent some time illustrating accessibility best practices in a subset of these samples.
ExpenseItIntro
ExpenseItDemo
DataBindingDemo
CustomComboBox
EditingExaminerDemo
License
Unless otherwise mentioned, the samples are released under the MIT license
Help us improve our samples
Help us improve out samples by sending us a pull-request or opening a GitHub Issue
WPF development
For current .NET version (.NET 10) - main branch
These samples require Visual Studio 2026(v18.1) to build, test, and deploy, and also require the most recent .NET 10 SDK.
Get a free copy of Visual Studio 2026 Community Edition
.NET 10 SDK
For older .NET versions - release/x.x branches
These samples require Visual Studio 2022(v17.7) to build, test, and deploy. Depending on the version of the applications you may need different SDKs.
Get a free copy of Visual Studio 2022 Community Edition
.NET 9 SDK
.NET 8 SDK
WPF on .NET has been open-sourced, and is now available on Github
Using the samples
To use the samples with Git, clone the WPF-Samples repository with 'git clone https://github.com/microsoft/WPF-Samples'
After cloning the WPF-Samples respository, there will be two solution files in the root directory: WPF-Samples.sln and WPF-Samples.msbuild.sln
To build the samples, open one of the solution files in Visual Studio 2022 and build the solution.
Alternatively, navigate to the directory of a sample and build with 'dotnet build' or 'msbuild' specifying the target project file.
WPF-Samples.msbuild.sln contains projects that can be built only with msbuild or Visual Studio, and will not compile with dotnet build. These projects contain C++ code, for which there is no support in dotnet build
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 2022.
Download the samples ZIP
Notes:
Before you unzip the archive, right-click it, select Properties, and then select Unblock.
Most samples should work independently
By default, all the samples target .NET 10.0. (Installers for the .NET 10 SDK can be found at )Top issues
#61gif as SplashScreen7 comments · 2018-11-21#294VideoViewerDemo does not indicate Windows feature dependency6 comments · 2020-05-15#677TitleBar buttons are scaled very small at a resolution of 4K (288 DPI)4 comments · 2024-12-17#432TouchKeyboard seems to depend on UWP3 comments · 2022-07-29#346DependencyProperty with collection properties3 comments · 2021-03-13#316invalid doc URLs; too old; nothing new3 comments · 2020-10-19#236WPF Application Samples.sln contains missing csproj refereces3 comments · 2019-12-25#680Sample Applications Update to Fluent Theme2 comments · 2025-02-03