Triggering data validation in WPF

I have a problem in WPF with validation.
I have a user control which has few textboxes, which are binding to datamodel.
The validation is implemented with IDataErrorInfo.

I want the validation to be triggered only when the user press the button "Submit data", so I used UpdateSourceTrigger="Explicit" with the binding of all those text boxes.

Everything working fine, and the validation only triggered when the user push the button, where I update the datasources.

But that user control can be hidden or shown, and when I changed the visibility from display/ to hidden and then back to display, the validation is triggered.

Is there a way to control the validation on that stage?

13.10.2009 16:37:14
Can you provide the code that actually updates the data source, and the XAML/code that changes the visibility of the user control? Is there any chance that the visibility change inadvertently calls the update code?
rdeetz 21.12.2009 14:42:25
<TextBox AutomationProperties.AutomationId="StreetNameTextBoxId" Height="20" Margin="0,0,5,0" FontSize="12" Name="_streetNameText" AcceptsReturn="False" AcceptsTab="False" Focusable="True" Text="{Binding ElementName=_this, Path=SearchParameters.EnteredAddress, UpdateSourceTrigger=Explicit}">
Ghassan Karwchan 21.12.2009 16:46:12
Can you show us the xaml for the button?
Phil 3.01.2010 20:26:35
1 ОТВЕТ

This is the code that I am using

The binding to the textbox

<TextBox
        AutomationProperties.AutomationId="StreetNameTextBoxId"
        Height="20" Margin="0,0,5,0" FontSize="12" Name="_streetNameText"
        AcceptsReturn="False" AcceptsTab="False" Focusable="True"
        Text="{Binding ElementName=_this, Path=SearchParameters.EnteredAddress, UpdateSourceTrigger=Explicit}">

The code that is executing the validation and search (which is associated to click of a button called "Search")

 private void ExecuteSearch() { 
        _streetNameText.UpdateDataSource();
        if (ViewModel.CustomerSpecification.IsValid())
            PerformActionInBackground(delegate{PerformSearch();});
    }
0
21.12.2009 18:07:21