BindingExpressionBase::ValidateWithoutUpdate Method ()

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Runs any ValidationRule objects on the associated Binding that have the ValidationStep property set to RawProposedValue or ConvertedProposedValue. This method does not update the source.

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

bool ValidateWithoutUpdate()

Return Value

Type: System::Boolean

true if the validation rules succeed; otherwise, false.

The ValidateWithoutUpdate method enables you to run validation rules on a binding without updating the source of the binding. This is useful when you want to validate user input and update the source at different times in an application.

For example, suppose you have a form to update a data source that contains a submit button. You want to provide feedback to the user if an invalid value is entered before the user attempts to submit the form. You can check the validity of a field by setting the binding's UpdateSourceTrigger property to Explicit and calling ValidateWithoutUpdate when the TextBox loses focus.

The following example demonstrates the scenario that is discussed in the Remarks section. The example enables a user to enter data for a library item and submit the data. The binding for the TextBox named callNum has a ValidationRule associated with it. When the TextBox loses focus, the example calls ValidateWithoutUpdate. When the user clicks the submit button, the example calls UpdateSource to commit the changes. The following XAML creates the user interface for the application.

        <Style TargetType="HeaderedContentControl">
            <Setter Property="Margin" Value="2"/>
            <Setter Property="Focusable" Value="False"/>
            <Setter Property="Template">
                    <ControlTemplate TargetType="HeaderedContentControl">
                        <DockPanel LastChildFill="False">
                            <ContentPresenter ContentSource="Header" DockPanel.Dock="Left" 
                              Focusable="False" VerticalAlignment="Center"/>
                            <ContentPresenter ContentSource="Content" Margin="5,0,0,0" 
                              DockPanel.Dock="Right" VerticalAlignment="Center"/>


    <HeaderedContentControl Header="Title">
        <TextBox Width="150" Text="{Binding Path=Title, Mode=TwoWay}"/>
    <HeaderedContentControl Header="Due Date">
        <TextBox Width="150" Text="{Binding Path=DueDate, StringFormat=d, Mode=TwoWay}">


    <HeaderedContentControl Header="Call Number">
        <TextBox Name="CallNum" Width="150"
                <Binding xmlns:src="clr-namespace:BindingExpressionBaseValidateWithoutUpdating"
                    Path="CallNumber" Mode="TwoWay"
                        <src:CallNumberRule ValidationStep="ConvertedProposedValue"/>

    <Button Click="Button_Click">Submit</Button>

    <HeaderedContentControl Header="Title">
        <TextBlock Text="{Binding Path=Title, Mode=TwoWay}"/>

    <HeaderedContentControl Header="Due Date">
        <TextBlock Text="{Binding Path=DueDate, StringFormat=d, Mode=TwoWay}"/>

    <HeaderedContentControl Header="Call Number">
        <TextBlock Text="{Binding CallNumber}"/>


The following example shows the logic for the user interface.

No code example is currently available or this language may not be supported.

The following example shows the data object and ValidationRule for the application.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 4.0
Return to top