2

everyone. Here is my question. I'm using MVVM pattern in my project and i have a UserControl, which has a TabControl on it. TabItems have validations on them.

Main page looks like this:

<UserControl>
    <DataInput:ValidationSummary x:Name="ValidationSummary"/>
    <Grid x:Name="LayoutRoot">
        <DataInput:ValidationSummary />
        <TabControl x:Name="TabControl">
            <TabItem>
                <MyUserControl1 DataContext="{Binding}" />
            </TabItem>
            <TabItem>
                <MyUserControl2 DataContext="{Binding}" />
            </TabItem>
            <TabItem>
                <MyUserControl2 DataContext="{Binding}" />
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>

And here is a sample code for TabItems:

<UserControl>
   <Grid>
     <Text:ExtendedTextBox Text="{Binding Name, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" />
     <Data:DataGrid SelectedItem="{Binding SelectedValue, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}"/>
   </Grid>
</UserControl>

Target for ValidationSummary is set to LayoutRoot. But actually, it's showing only errors for visible(currently opened) TabItem. And i need to show all the errors from all tabs. How can i achieve this?

vlaku
  • 1,534
  • 2
  • 14
  • 27
  • You don't need `DataContext="{Binding}"` in your UserControl's. Using the parent's DataContext is the default behavior. – Stephan Aug 04 '10 at 14:46

1 Answers1

4

Walkor, see this: Using BindingValidationError to Add Messages to a Validation Summary in Silverlight

Hope helps!

Sue Maurizio
  • 662
  • 7
  • 17
Matjaz Bravc
  • 189
  • 1
  • 12