TabControl 中的验证摘要 (Silverlight 4)
每个人。这是我的问题。我在我的项目中使用 MVVM 模式,并且我有一个 UserControl,上面有一个 TabControl。 TabItems 有验证。
主页如下所示:
<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 的示例代码:
<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 的错误。我需要显示所有选项卡中的所有错误。我怎样才能做到这一点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Walkor,请参阅此:使用BindingValidationError 在 Silverlight 中将消息添加到验证摘要
希望有所帮助!
Walkor, see this: Using BindingValidationError to Add Messages to a Validation Summary in Silverlight
Hope helps!