摘要:
准备一个类 1 public class MethodCLass 2 { 3 public void Method() 4 { 5 Console.WriteLine($"无参方法"); 6 return; 7 } 8 9 public void Method(int arg) 10 { 11 Co 阅读全文
摘要:
效果 还是准备一个ViewModel 在要验证的属性上面添加验证特性 1 public class ViewModel 2 { 3 private int _age; 4 5 private string _eMail; 6 7 private string _name; 8 9 [Range(0, 阅读全文
摘要:
效果 首先准备一个ViewModel类 实现IDataErrorInfo接口 1 public class ViewModel : INotifyPropertyChanged, IDataErrorInfo 2 { 3 private string _error; 4 5 public int A 阅读全文
摘要:
效果 首先添加引用 System.Windows.Interactivity.WPF (需要用nuget包下载) 准备一个行为类 继承Behavior类 1 /// <summary> 2 /// 控件获取焦点后的行为 3 /// </summary> 4 public class FocusBeh 阅读全文
摘要:
效果 首先 准备一个装饰器类 继承Adorner 1 /// <summary> 2 /// 装饰器必须继承抽象类Adorner 3 /// </summary> 4 public class CornerAdorner : Adorner 5 { 6 /// <summary> 7 /// 调用基 阅读全文
摘要:
准备一个数字验证规则类 继承ValidationRule 1 public class NumberValidationRule : ValidationRule 2 { 3 private int _max = 150; 4 private int _min = 0; 5 6 /// <summa 阅读全文
摘要:
记忆一下,以防遗忘 定义一个接口 1 public interface IPropertyValidation 2 { 3 /// <summary> 4 /// 验证失败后的错误信息 5 /// </summary> 6 string ErrorInfo { get; set; } 7 8 /// 阅读全文
摘要:
写在这里,以备遗忘!!! 准备一个特性类 1 [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)] 2 internal class NickNameAttribute : Attribute 3 { 4 public s 阅读全文
摘要:
常用数据校验特性可以查看 System.ComponentModel.DataAnnotations 命名空间 AssociatedMetadataTypeTypeDescriptionProvider 通过添加在关联类中定义的特性和属性信息,从而扩展某个类的元数据信息。 AssociationAt 阅读全文
摘要:
对于类里面的成员的值类型和引用类型的概念一直有点模糊,写个例子加深记忆 第一种 新建2个类 1 class Box 2 { 3 4 public Item Item { get; set; }//引用类型 5 public Box(Item item) => this.Item = item; 6 阅读全文