Getting started

edit

Install the package

Add the Meziantou.Framework.WPF package to a WPF application:

dotnet package add Meziantou.Framework.WPF

The package targets Windows, so the project must target Windows and enable WPF:

<PropertyGroup>
  <TargetFramework>net10.0-windows</TargetFramework>
  <UseWPF>true</UseWPF>
</PropertyGroup>

Use it from C#

The C# examples of this documentation omit the using directives: they need using Meziantou.Framework.WPF;.

Use it from XAML

Declare an XML namespace for the assembly on the root element of the XAML file, then prefix the types with it. For instance, to close a window when the user presses Escape:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:wpf="clr-namespace:Meziantou.Framework.WPF;assembly=Meziantou.Framework.WPF"
        wpf:WindowUtilities.CloseOnEscapeKeyDown="True">
</Window>

The XAML examples of this documentation use the wpf prefix for this namespace.

Next steps

  • Commands: bind buttons to the methods of a view model.
  • Enum values: fill a combo box with the values of an enum.