UpdateSourceExceptionFilterCallback UpdateSourceExceptionFilterCallback UpdateSourceExceptionFilterCallback UpdateSourceExceptionFilterCallback Delegate


Represents the method that handles exceptions that are thrown during the update of the binding source value. This must be used with the ExceptionValidationRule.

public delegate System::Object ^ UpdateSourceExceptionFilterCallback(System::Object ^ bindExpression, Exception ^ exception);
public delegate object UpdateSourceExceptionFilterCallback(object bindExpression, Exception exception);
type UpdateSourceExceptionFilterCallback = delegate of obj * Exception -> obj
Public Delegate Function UpdateSourceExceptionFilterCallback(bindExpression As Object, exception As Exception) As Object 


Object Object Object Object

The object with the exception.

Exception Exception Exception Exception

The exception encountered.

Return Value


An object that is typically one of the following:

Value Description
null To ignore any exceptions. The default behavior (if there is no UpdateSourceExceptionFilterCallback) is to create a ValidationError with the exception and adds it to the Errors collection of the bound element.
Any object To create a ValidationError object with the ErrorContent set to that object. The ValidationError object is added to Errors collection of the bound element.
A ValidationError object To set the BindingExpression or MultiBindingExpression object as the BindingInError. The ValidationError object is added to 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 have the option to 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.";

For the complete sample, see Binding Validation Sample.


If you have associated the ExceptionValidationRule with your Binding object you have the option to use the UpdateSourceExceptionFilter property to set this callback to provide custom logic for handling the exceptions. This callback is invoked whenever any exception is encountered when the binding engine updates the binding source value.

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.

Extension Methods

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

Gets an object that represents the method represented by the specified delegate.

Applies to

See also