WPF : Validation

Validation Rule 简单示例 class ViewModel { public int Number { get; set; } } TextBox TextBox.Text Binding Path=Number UpdateSourceTrigger=PropertyChanged Delay=200 /Binding /TextBox.Text /TextBox 示例中由于绑定的属性Number是int型(int在绑定到界面上时会自动添加int⇋string的converter),所以当我们输入非数字时,converter抛出的转换异常会被捕获到,此时Textbox上会出现红色边框。 异常被捕获 描述错误的实际消息存储在 System.Windows.Controls.ValidationError 对象的 …

.Net WPF Validation

Merge Multiple .Net Assemblies Into One

When we use a lot of external dependencies, the generated folder may contain a lot of Dlls that are not conducive to distribution. Before Here are two ways to pack multiple assemblies into one. Costura.Fody Costura is an add-in for Fody. Fody is an extensible tool for weaving .net assemblies. It enables the manipulating the IL of an assembly as part of a build. Costura is easy to use. Install …

.Net IL Merge Fody

WPF基础Ⅱ: 依赖属性

依赖属性 与.Net属性对比: 更高效 支持附加功能 更改通知 属性值继承 创建依赖属性 /// summary /// 只能为依赖对象添加依赖属性 /// /summary public class DependencyClass : DependencyObject { /// summary /// 定义依赖属性 /// 约定俗成命名规则:属性名+Property /// /summary public static readonly DependencyProperty NumberProperty = DependencyProperty.Register(//注册依赖属性 Number, //属性名 typeof(int), //属性类型 …

.Net WPF


基础 XAML单位 一个设备无关单位被定义为1/96英寸 标准Windows dpi为96 dpi 设备无关单位 * 系统dpi = 实际像素数 (eg: 1/96英寸 * 96dpi =1像素) XAML命名空间 使用特殊特性 xmlns 声明命名空间 命名空间可使用XML名称空间或者**.Net名称空间** # XML名称空间 使用URI xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml # .Net名称空间 使用类的完整名称 xmlns:Prefix=clr-namespace:Namespace;assembly=AssemblyName XAML属性 简单属性 可直接设置属性值 Grid …

.Net WPF

Generate a True Metafile in .NET

A few days ago when I was building the MS-OLEDS file for AutoCAD, I needed to create a Metafile as part of it. However, I encountered some small problems when using the built-in API. The Problem with Built-in API In System.Drawing.Imaging has a Metafile Class that allows us do a sequence of graphics operations on it.Here is my code and the test file in the HEX editor. public static void …

.Net Metafile

.Net MD5算法与系统FIPS兼容性

使用dotNet框架自带的Md5加密MD5CryptoServiceProvider时,在部分电脑上会出现InvalidOperationException. System.InvalidOperationException: 此实现不是 Windows 平台 FIPS 验证的加密算法的一部分。 在 System.Security.Cryptography.MD5CryptoServiceProvider..ctor() 出现的原因是系统启用了FIPS兼容算法,而FIPS标准并不支持MD5,所以当框架中的MD5算法调用系统的加密模块时就会爆异常. FIPS 140-2 defines security standards that the United States and Canadian governments use to validate security levels …

.Net MD5

  • 1