SilverLight.3-Validation:二、银光验证。TheLabel、TheDescriptionViewer和TheValidationSummary
| ylbtech-SilverLight.3-DataControls_BetterDataFroms:二、银光验证。TheLabel、TheDescriptionViewer和TheValidationSummary |
- 1.A, 数据源
- 1.B, TheLabel
- 1.C, TheDescriptionViewer
- 1.D, TheValidationSummary
| 1.A, 数据源返回顶部 |
using System; using System.ComponentModel.DataAnnotations;
namespace SL3ValidationYlbtechApp.Access
{
/// <summary>
/// 人类
/// </summary>
public class Person
{
int _personId;
/// <summary>
/// 编号【PK】
/// </summary>
public int PersonId
{
get { return _personId; }
set { _personId = value; }
}
string _username; //长度
/// <summary>
/// 姓名
/// </summary>
[Display(Name = "姓名", Description = "不许为空")]
public string Username
{
get { return _username; }
set
{
if (value == "") throw new ArgumentException("不许为空");
_username = value;
}
}
string _sex; //用户自定义
/// <summary>
/// 性别【CK】男|女|未知
/// </summary>
public string Sex
{
get { return _sex; }
set { _sex = value; }
}
int _age; //范围
/// <summary>
/// 年龄
/// </summary>
[Display(Name="年龄",Description="必须大于0")]
public int Age
{
get { return _age; }
set
{
if (value < ) throw new ArgumentException("不能小于0");
_age = value;
}
}
string _email; //正则
/// <summary>
/// 电子邮箱
/// </summary>
public string Email
{
get { return _email; }
set { _email = value; }
}
DateTime _addedDate;
/// <summary>
/// 添加日期
/// </summary>
public DateTime AddedDate
{
get { return _addedDate; }
set { _addedDate = value; }
}
string _description;
/// <summary>
/// 描述
/// </summary>
public string Description
{
get { return _description; }
set { _description = value; }
} /// <summary>
/// 空参构造
/// </summary>
public Person() { }
/// <summary>
/// 全参构造
/// </summary>
/// <param name="personId"></param>
/// <param name="username"></param>
/// <param name="sex"></param>
/// <param name="age"></param>
/// <param name="email"></param>
/// <param name="addedDate"></param>
/// <param name="description"></param>
public Person(int personId, string username, string sex, int age, string email
, DateTime addedDate, string description)
{
_personId = personId;
_username = username;
_sex = sex;
_age = age;
_email = email; _addedDate = addedDate;
_description = description;
} /// <summary>
/// GetModel
/// </summary>
/// <returns></returns>
public static Person GetModel()
{
Person dal = new Person(, "rain", "男", , "ylbtech@qq.com"
, new DateTime(, , ), "静以修身,俭以养德");
return dal;
}
}
}
4,
| 1.B, TheLabel返回顶部 |

xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
2.2/3,
<Grid x:Name="gridDetailPerson" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Margin="7" Text="姓名"></TextBlock>
<TextBox Grid.Row="0" Grid.Column="1" Margin="5" Text="{Binding Username}"></TextBox> <my:Label Grid.Row="1" Grid.Column="0" Margin="7" Content="年龄" Target="{Binding ElementName=txtAge}" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5" x:Name="txtAge"
Text="{Binding Age,Mode=TwoWay, ValidatesOnExceptions=True,NotifyOnValidationError=True}"></TextBox>
</Grid>
2.3/3,
using System.Windows.Controls; using SL3ValidationYlbtechApp.Access;
namespace SL3ValidationYlbtechApp.DataControls.BetterDataForms
{
public partial class TheLabel : UserControl
{
public TheLabel()
{
InitializeComponent(); gridDetailPerson.DataContext = Person.GetModel();
}
}
}
3,
Target="{Binding ElementName=txtAge}"
| 1.C, TheDescriptionViewer返回顶部 |

<Grid x:Name="gridDetailPerson" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<my:Label Grid.Row="0" Grid.Column="0" Margin="7" Content="姓名" Target="{Binding ElementName=txtUsername}" />
<TextBox Grid.Row="0" Grid.Column="1" Margin="5" x:Name="txtUsername"
Text="{Binding Username,Mode=TwoWay, ValidatesOnExceptions=True,NotifyOnValidationError=True}"></TextBox>
<my:DescriptionViewer Grid.Row="0" Grid.Column="2" Target="{Binding ElementName=txtUsername}"></my:DescriptionViewer> <my:Label Grid.Row="1" Grid.Column="0" Margin="7" Content="年龄" Target="{Binding ElementName=txtAge}" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5" x:Name="txtAge"
Text="{Binding Age,Mode=TwoWay, ValidatesOnExceptions=True,NotifyOnValidationError=True}"></TextBox>
<my:DescriptionViewer Grid.Row="1" Grid.Column="2" Target="{Binding ElementName=txtAge}">
<my:DescriptionViewer.GlyphTemplate>
<ControlTemplate>
<Image Source="reg1.jpg" Stretch="None"></Image>
</ControlTemplate>
</my:DescriptionViewer.GlyphTemplate>
</my:DescriptionViewer>
</Grid>
2.1/3, 代码同上文1.B.2.3/3
<my:DescriptionViewer Grid.Row="1" Grid.Column="2" Target="{Binding ElementName=txtAge}">
<my:DescriptionViewer.GlyphTemplate>
<ControlTemplate>
<Image Source="reg1.jpg" Stretch="None"></Image>
</ControlTemplate>
</my:DescriptionViewer.GlyphTemplate>
</my:DescriptionViewer>
4,
| 1.D, TheValidationSummary返回顶部 |

<Grid x:Name="gridDetailPerson" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<my:Label Grid.Row="0" Grid.Column="0" Margin="7" Content="姓名" Target="{Binding ElementName=txtUsername}" />
<TextBox Grid.Row="0" Grid.Column="1" Margin="5" x:Name="txtUsername"
Text="{Binding Username,Mode=TwoWay, ValidatesOnExceptions=True,NotifyOnValidationError=True}"></TextBox> <my:Label Grid.Row="1" Grid.Column="0" Margin="7" Content="年龄" Target="{Binding ElementName=txtAge}" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5" x:Name="txtAge"
Text="{Binding Age,Mode=TwoWay, ValidatesOnExceptions=True,NotifyOnValidationError=True}"></TextBox> <my:ValidationSummary Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" ></my:ValidationSummary>
</Grid>
2.1/3, 代码同上文1.B.2.3/3
<TextBox Margin="5" x:Name="txtPrice" Width="100" HorizontalAlignment="Left"
my:ValidationSummary.ShowErrorsInSummary="False"
Text="{Binding UnitCost, Mode=TwoWay, ValidatesOnExceptions=true,
NotifyOnValidationError=true}"></TextBox>
4,
| 1.E,返回顶部 |
![]() |
作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
SilverLight.3-Validation:二、银光验证。TheLabel、TheDescriptionViewer和TheValidationSummary的更多相关文章
- SilverLight.3-Validation:一、银光验证。ValidatesOnExpression和NotifyOnValidationError
ylbtech-SilverLight-DataBindings_BindingADataObjects_Validation:一.银光验证.ValidatesOnExpression和NotifyO ...
- jQuery学习之:Validation表单验证插件
http://polaris.blog.51cto.com/1146394/258781/ 最近由于公司决定使用AJAX + Struts2来重构项目,让我仔细研究一下这两个,然后集中给同事讲讲,让每 ...
- java实现谷歌二步验证 (Google Authenticator)
准备: 一个谷歌二步验证APP, 我用的是ios 身份宝 资料: 1.Google Authenticator 原理及Java实现 //主要参考 https://blog.csdn.net/li ...
- Force.com微信企业号开发系列(一) - 启用二次验证
微信于9月份推出企业号后引起了业界不小的反响,许多企业都在思索企业号将如何影响企业的运营,从本文开始,我将详细阐述微信企业号开发的相关知识,而本文将着重介绍如何实现更高安全机制的二次验证. 申请企业体 ...
- destoon 深度整合discuz x2 UC 之免邮箱二次验证
destoon中member/my.php,信息发布入口处判断是否已在dx中做了验证,如果已经验证,则不再提示验证,否则其中dt的验证页面. 在home.php.php. group.php. for ...
- 基于RSA securID的Radius二次验证java实现(PAP验证方式)
基于rsa SecurID的二次验证.RSA server自身可以作为Radius服务器,RSA也可以和其他的软件集合,使用其他的server作为Radius服务器. radius的验证的一般流程如下 ...
- GitHub中开启二次验证Two-factor authentication,如何在命令行下更新和上传代码
最近在使用GitHub管理代码,在git命令行管理代码时候遇到一些问题.如果开起了二次验证(Two-factor authentication两个要素认证),命令行会一直提示输入用户名和密码.查找了一 ...
- emqtt 试用(二)验证 emq 和 mosquito 的共享订阅
本地订阅(Local Subscription) 本地订阅(Local Subscription)只在本节点创建订阅与路由表,不会在集群节点间广播全局路由,非常适合物联网数据采集应用. 使用方式: 订 ...
- In-App Purchase iap 内付费 二次验证代码 (java 服务器端)
参考网址:https://blog.csdn.net/a351945755/article/details/22919533 package com.yichangmao.buyVerify.Comm ...
随机推荐
- icpc南昌邀请赛 比赛总结
上周末,我参加了icpc南昌区域赛邀请赛,这也是我的第一次外出参赛. 星期五晚上,在6个小时的火车和1个小时的公交后,我们终于抵达了江西师范大学,这次的比赛场地.江西师范大学周围的设施很齐全,各种烧烤 ...
- 从输入url开始,完善前端体系架构
原文链接: https://segmentfault.com/a/1190000013662126 从输入URL到页面加载的过程?如何由一道题完善自己的前端知识体系! javascript 前端 23 ...
- Linux互斥锁、条件变量和信号量
Linux互斥锁.条件变量和信号量 来自http://kongweile.iteye.com/blog/1155490 http://www.cnblogs.com/qingxia/archive/ ...
- jquery的html、text、val的用法
.html()用为读取和修改元素的HTML标签 .text()用来读取或修改元素的纯文本内容 .val()用来读取或修改表单元素的value值. 这三个方法功能上的对比 .html(),.text() ...
- 【转】Visual Studio 2013 Tools for Unity安装目录,Visual Studio 2013 Tools.unitypackage
http://blog.csdn.net/dynastyting/article/details/46505349 Visual Studio 2013 Tools for Unity安装目录 D:\ ...
- jquery怎样获取html页面中的data-xxx
$(this).attr("data-id") // will return the string "123"or .data() (if you use ne ...
- MAC抓包工具charles(青花瓷)
下载链接:http://pan.baidu.com/s/1pL6ClBX 配置教程:http://blog.csdn.net/jiangwei0910410003/article/details/41 ...
- hihoCoder [Offer收割]编程练习赛83 D 生成树问题
题目 从 Kruskal 算法的角度来思考这个问题. 考虑 $n$ 个点的"空图"(即没有边的图). 先将 $m_2$ 条无权值的边加到图中,得到一个森林. 按边权从小到大的顺序枚 ...
- pat 甲级 1053. Path of Equal Weight (30)
1053. Path of Equal Weight (30) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...
- [NOIP2013] 提高组 洛谷P1979 华容道
题目描述 [问题描述] 小 B 最近迷上了华容道,可是他总是要花很长的时间才能完成一次.于是,他想到用编程来完成华容道:给定一种局面, 华容道是否根本就无法完成,如果能完成, 最少需要多少时间. 小 ...
