WpfBindingErrors icon indicating copy to clipboard operation
WpfBindingErrors copied to clipboard

:boom: Turn WPF Binding errors into exception

Turn WPF binding errors into exceptions

A lightweight library that converts WPF binding errors into exceptions, so you can quickly spot errors in the XAML markup and detect them unit tests.

Exception shown in Visual Studio

All it requires is a single line in your existing code:

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs args)
    {
        base.OnStartup(args);
        
        // Start listening for WPF binding error.
        // After that line, a BindingException will be thrown each time
        // a binding error occurs.
        BindingExceptionThrower.Attach();
    }
}

Installing:

With .NET CLI

> dotnet add package WpfBindingErrors

With Package Manager:

PM> Install-Package WpfBindingErrors

https://www.nuget.org/packages/WpfBindingErrors

Content

  1. Project WpfBindingError is a reusable assembly that listens for binding errors.
  2. Project SampleWpfApplication shows how to throw BindingException at runtime.
  3. Project SampleWpfApplicationTests shows how to check binding errors in a unit test project.

Each project contains a dedicated README with more detail.

Supported frameworks

  • .NET Core 3.0 🆕
  • .NET Framework 4.6
  • .NET Framework 4.5.2
  • .NET Framework 4.5.1
  • .NET Framework 4.5
  • .NET Framework 4.0

Contributors