WPF ValidationRule的特点(默认目标-源才校验)
默认是当目标发生改变时候,通过绑定改变源时候进行校验,因为WPF认为源是安全的,如果想让源改变时候,也进行校验则设置验证规则的ValidatesOnTargetUpdated =true
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace XamlTest
{
/// <summary>
/// Interaction logic for Window16.xaml
/// </summary>
public partial class Window16 : Window
{
public Window16()
{
InitializeComponent();
Binding b = new Binding();
b.Source= slider;
b.Path = new PropertyPath("Value");
b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
RangeValidationRule vr = new RangeValidationRule();
//vr.ValidatesOnTargetUpdated =true;
b.NotifyOnValidationError = true;
b.ValidationRules.Add(vr);
txt.SetBinding(TextBox.TextProperty, b);
txt.AddHandler(Validation.ErrorEvent,new RoutedEventHandler(this.ValidationError));
}
private void ValidationError(object sender, RoutedEventArgs e)
{
if (Validation.GetErrors(txt).Count>0)
{
txt.ToolTip = Validation.GetErrors(txt)[0].ErrorContent.ToString();
}
}
}
}
WPF ValidationRule的特点(默认目标-源才校验)的更多相关文章
- Ubuntu14.04和16.04官方默认更新源sources.list和第三方源推荐(干货!)
不多说,直接上干货! 写在前面:笔者由于还在学校学习,学校没有开发给Linux用的上网客户端,所以只能用在windows系统中通过安装虚拟机运行linux比较方便,但没有外网,只有学校的教育网,所以我 ...
- buntu14.04和16.04官方默认更新源sources.list和第三方源推荐(干货!)转
配置完成后: sudo apt-get update 安装和删除软件: sudo apt-get install sudo apt-get remove buntu14.04和16.04官方默认更新源 ...
- Linux下更换默认yum源为网易yum源的操作记录
废话不多说,下面记录了centos下更换系统默认yum源为网易yum源的操作过程:1)备份原有的默认yum源[root@bastion-IDC ~]# cp /etc/yum.repos.d/Cent ...
- Ubuntu 14.04.4官方默认更新源sources.list
Ubuntu 14.04.4官方默认更新源sources.list # deb cdrom:[Ubuntu LTS _Trusty Tahr_ - Release amd64 (20160217.1) ...
- HTML <base> 标签 为页面上的所有链接规定默认地址或默认目标
定义和用法 <base> 标签为页面上的所有链接规定默认地址或默认目标. 通常情况下,浏览器会从当前文档的 URL 中提取相应的元素来填写相对 URL 中的空白. 使用 <base& ...
- 修改CentOS默认yum源为国内yum镜像源
CentOS默认的yum源不是国内的yum源,在通过yum安装一些软件的时候,会出现这样那样的错误,以及在下载安装的速度上也是非常慢的. 所以这个时候就需要将yum源替换成国内的yum源,国内主要开源 ...
- CentOS修改默认yum源为国内yum镜像源
修改CentOS默认yum源为mirrors.163.com 1.首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repomv /etc/yum.repos. ...
- docker切换默认镜像源
docker切换默认镜像源 基于 debian8 默认安装的 docker 镜像源是在国外,pull 镜像的时候奇慢无比,需要自己手动切换成国内的镜像源. 1. 修改配置文件 docker 默认的 ...
- Intellij IDEA Debug 多模块下断点目标源问题
Ctrl+Alt+S进入Settings,选择Debugger->show alternative source switcher 勾选,开启显示替代源选择器 由于项目工程存放了多个应用模块,包 ...
随机推荐
- 远程登录DSM,显示“您没有权限使用本项服务?
远程登录DSM,显示“您没有权限使用本项服务?” https://www.chiphell.com/thread-825297-1-1.html 有可能你单位用的是多wan接入.一般synology不 ...
- WP8.1:onedrive操作
小梦今天给大家分享一下windows phone 8.1开发 onedrive中的一些操作: Windows phone 8.1 中 onedrive 登录 Windows phone 8.1 中 o ...
- Linux基本命令(二)
1. 输出重定向命令:> Linux允许将命令执行结果重定向到一个文件,本应显示在终端上的内容保存到指定文件中. 如:ls > test.txt ( test.txt 如果不存在,则创建, ...
- ios开发瀑布流框架的封装
一:瀑布流框架封装的实现思路:此瀑布流框架的封装仿照tableView的底层实现,1:每个cell的frame的设置都是找出每列的最大y值,比较每列的最大y值,将下一个cell放在最大y值最小的那一列 ...
- ahks
!+F11:: newStr := clipboard ;newStr := RegExReplace(newStr, "<[^>]*>", "&quo ...
- IT增值服务客户案例(二):河南郑州大四实习生,职业规划和项目开发指导
客户整体情况,河南郑州大四在校学生,目前在企业实习,从事Java开发工作.有一定的项目开发经验,对Java周边技术有基本的理解. 客户购买的是"拜师学艺"服务,按月付款. 经过多次 ...
- [React Router v4] Style a Link that is Active with NavLink
We often need to be able to apply style to navigation links based on the current route. In React Rou ...
- Android Studio 连接自己搭建的server 须要admin 的帐号的问题 SSH Password Login,please enter password for user git@git.
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...
- js进阶 9-5 js如何确认form的提交和重置按钮
js进阶 9-5 js如何确认form的提交和重置按钮 一.总结 一句话总结: 1.这个并不好做:onsubmit 里面的代码必须返回false才能取消onsubmit方法的执行,所以,有return ...
- 使用nodejs 来压缩整个目录
var fstream = require('fstream'), tar = require('tar'), zlib = require('zlib'); fstream.Reader({ 'pa ...