This documentation is archived and is not being maintained.

Binding.UpdateSourceExceptionFilter Property

Gets or sets a handler you can use to provide custom logic for handling exceptions that the binding engine encounters during the update of the binding source value. This is only applicable if you have associated an ExceptionValidationRule with your binding.

Namespace: System.Windows.Data
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:

property UpdateSourceExceptionFilterCallback^ UpdateSourceExceptionFilter {
	UpdateSourceExceptionFilterCallback^ get ();
	void set (UpdateSourceExceptionFilterCallback^ value);
/** @property */
public UpdateSourceExceptionFilterCallback get_UpdateSourceExceptionFilter ()

/** @property */
public void set_UpdateSourceExceptionFilter (UpdateSourceExceptionFilterCallback value)

public function get UpdateSourceExceptionFilter () : UpdateSourceExceptionFilterCallback

public function set UpdateSourceExceptionFilter (value : UpdateSourceExceptionFilterCallback)

You cannot use this property in XAML.

Property Value

A method that provides custom logic for handling exceptions that the binding engine encounters during the update of the binding source value.

The ExceptionValidationRule is a built-in validation rule that checks for exceptions thrown during the update of the binding source property. If you have associated the ExceptionValidationRule with your Binding object, you can use this property to set a handler to provide custom logic for handling these exceptions. If an UpdateSourceExceptionFilter is not specified on the Binding, the binding engine creates a ValidationError with the exception and adds it to the Validation.Errors collection of the bound element.

The Text property of the following TextBox is data-bound to a source property Age3 that is of type int. The ExceptionValidationRule checks for exceptions that are thrown during the update of the source property (such as when the user enters a value that cannot be converted to an integer).

<TextBox Name="textBox3" Width="50" FontSize="15"
         Grid.Row="4" Grid.Column="1" Margin="2"
         Validation.ErrorTemplate="{StaticResource validationTemplate}"
         Style="{StaticResource textBoxInError}">
    <Binding Path="Age3" Source="{StaticResource ods}"

You can provide custom logic to handle those exceptions. The following example shows how to use the UpdateSourceExceptionFilter property to set an UpdateSourceExceptionFilterCallback.

BindingExpression myBindingExpression = textBox3.GetBindingExpression(TextBox.TextProperty);
Binding myBinding = myBindingExpression.ParentBinding;
myBinding.UpdateSourceExceptionFilter = new UpdateSourceExceptionFilterCallback(ReturnExceptionHandler);

The following is an example implementation of an UpdateSourceExceptionFilterCallback.

object ReturnExceptionHandler(object bindingExpression, Exception exception)
    return "This is from the UpdateSourceExceptionFilterCallBack.";

The UpdateSourceExceptionFilterCallback can also return a null reference (Nothing in Visual Basic), the exception itself, or a ValidationError. For more information, see UpdateSourceExceptionFilterCallback.

For the complete sample, see Binding Validation Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0