Mindscape WPF Elements使用教程:错误管理
来源:互联网 发布:怎样避免淘宝客 编辑:程序博客网 时间:2024/06/06 11:39
原文转载自慧都控件网:http://www.evget.com/zh-CN/Info/catalog/18232.html
提高错误管理
在Mindscape WPF Elements中现在又优化了错误管理,可以通过定制属性网格来提供更多的信息的错误处理。
修改自定义编辑器
在Mindscape WPF Elements中提供了一个自定义编辑属性,你可以创建你的错误管理的用户界面来作为你模版的一部分,下面的代码显示“英尺和尺寸”的编辑器使用tooltip和弹出窗口用来显示验证错误。
附加验证的编辑器
<DataTemplate x:Key='FeetAndInchesEditorWithValidation'> <ms:TextBox BorderThickness='0' Text='{Binding Value, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource FeetAndInchesConverter}, ValidatesOnExceptions=True, ValidatesOnDataErrors=True}' Style='{StaticResource TextBoxStandardErrorHandling}'> </ms:TextBox> </DataTemplate>
常见样式的文本处理验证错误
<Style TargetType='{x:Type ms:TextBox}' x:Key='TextBoxStandardErrorHandling'> <Setter Property='Control.Template'> <Setter.Value> <ControlTemplate TargetType='{x:Type ms:TextBox}'> <DockPanel> <ToggleButton x:Name='ErrorPlaceholder' Style='{StaticResource ErrorPopupTriggerStyle}'/> <Popup PlacementTarget='{Binding ElementName=ErrorPlaceholder}' AllowsTransparency='True' StaysOpen='False' Placement='Bottom' IsOpen='{Binding ElementName=ErrorPlaceholder, Path=IsChecked}'> <ItemsControl ItemTemplate='{StaticResource ValidationErrorMessage}' ItemsSource='{Binding RelativeSource={RelativeSource AncestorType={x:Type ms:TextBox}}, Path=(Validation.Errors)}'/> </Popup> <ScrollViewer x:Name='PART_ContentHost'/> </DockPanel> <ControlTemplate.Triggers> <Trigger Property='Validation.HasError' Value='True'> <Setter TargetName='ErrorPlaceholder' Property='Visibility' Value='Visible'/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> <Setter Property='Validation.ErrorTemplate'> <Setter.Value> <ControlTemplate> <DockPanel> <Ellipse Margin='0,0,6,0' ToolTip='{Binding ElementName=EditorHolder, Path=AdornedElement.(Validation.Errors)[0], Converter={StaticResource InnerExceptionExtractor}}' Width='8' Height='8' Fill='Red'/> <AdornedElementPlaceholder x:Name='EditorHolder'/> </DockPanel> </ControlTemplate> </Setter.Value> </Setter> </Style>
内置的编辑器样式
对于内置编辑器的属性,可以使用样式通过属性编辑器来创建你的错误处理的用户界面。
还可以定义错误处理用户接口,通过内置编辑器的所有实例来应用,而不是在属性和属性的基础上,使用BuiltInEditorStyles属性。这个例子展示了如何添加错误处理到文本编辑器,值得注意FirstName和Surname着两种属性会自动的得到新的样式,尽管没有自定义风格的属性编辑器分配给这两个属性。
添加错误处理到内置文本编辑器
<ms:PropertyGrid.BuiltInEditorStyles> <ms:BuiltInEditorStyleCollection> <ms:BuiltInEditorStyle EditorKey='{x:Static ms:PropertyGrid.SimpleTextEditorKey}' Style='{StaticResource TextBoxStandardErrorHandling}'/> </ms:BuiltInEditorStyleCollection> </ms:PropertyGrid.BuiltInEditorStyles>
- Mindscape WPF Elements使用教程:错误管理
- Mindscape WPF Elements使用教程:排序、过滤和分组
- Mindscape WPF Elements构建仪表教程
- Mindscape WPF Elements构建超炫仪表盘系列教程
- Mindscape WPF Elements中进程控件的使用
- 揭秘Mindscape WPF Elements 5新特性
- WPF Elements数据网格使用教程
- WPF Elements用户界面套包数据网格教程
- .NET界面工具WPF Elements中文教程
- 【网摘】WPF Elements数据网格使用笔记
- WPF InkCanvas 基础使用教程
- WPF教程(十)使用App.xaml
- WPF简单教程:Application类的使用
- WPF教程
- wpf教程
- 探究WPF Elements 5.1新特性
- Git版本管理使用教程
- 代码管理_SVN_TortoiseSVN使用教程
- 解决AIX5.3环境下,重复启动weblogic造成的锁死
- 从头学TAO编程系列 获取并编译TAO
- 成绩单(~ o ~)~zZ
- 图解数据结构(5)——散列法及哈希表
- 继承与派生类 学习笔记3--虚基类
- Mindscape WPF Elements使用教程:错误管理
- java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
- Java Applet使用简记
- 从头学TAO编程系列 编写最简单的TAO应用程序
- 关于SQL内部执行的中top和order by顺序先后的论证
- 黑马程序员--表格的应用和布局
- LightOJ 1211 Intersection of Cubes
- php基础学习
- Web开发者必知的8个超实用API