问题描述
大家.这是我的问题.我在我的项目中使用 MVVM 模式,我有一个 UserControl,它上面有一个 TabControl.TabItem 对其进行了验证.
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.
主页看起来像这样:
<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>
这是 TabItems 的示例代码:
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>
ValidationSummary 的目标设置为 LayoutRoot.但实际上,它只显示可见(当前打开)TabItem 的错误.我需要显示所有选项卡中的所有错误.我怎样才能做到这一点?
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?
推荐答案
Walkor,请参阅:使用 BindingValidationError 将消息添加到 Silverlight 中的验证摘要
Walkor, see this: Using BindingValidationError to Add Messages to a Validation Summary in Silverlight
希望有帮助!
这篇关于TabControl (Silverlight 4) 中的验证摘要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!