05 2013 档案

摘要:WPF学习:5.依赖属性 前一章主要介绍了类型扩展和标记转换,这一章主要介绍WPF中一个重要的特性-依赖属性。按照惯例,先贴上示例代码:http://files.cnblogs.com/keylei203/5.BindingDP.zip。一个新的属性系统 依赖属性的设计思想就是侧重于属性超过方法和事件,能用属性解决的问题解决不使用方法和事件,以往的属性功能太单一,仅仅是提供一个类型的值,WPF提供了一个新的属性类型即依赖属性和与之配套的服务,让它能做方法和事件所能做的事情。 依赖属性和一般的CLR属性大部分相似,那么这种新的属性系统的优势在哪里呢,下面让我们看看依赖属性和CLR属性的区别... 阅读全文
posted @ 2013-05-28 10:55 若愚Shawn 阅读(342) 评论(0) 推荐(0)
摘要:一、普通属性首先我们来探讨下.NET里面的属性,我们平时写一个类的时候我们需要定义一些字段来保存一些值。public class Person{ public string nam; public int age;}但是我们会发现,这样子定义的话不能满足我们的需求,比如说我们需要实现一些对字段值得验证限制什么的,这时候我们就需要属性来为我们实现了。因为我们能在给属性设置的时候编写我们的验证逻辑。public class Person{ private string name; private int age; public int Age { get{retur... 阅读全文
posted @ 2013-05-28 10:40 若愚Shawn 阅读(254) 评论(0) 推荐(0)
摘要:简介 一个绑定常常由四部分组成:绑定源、路径、绑定目标及目标属性,同时转换器也是一个非常重要的组成。源用来标示源属性所存在的类型实例,路径用来标示需要绑定到的处于绑定源之上的源属性,绑定目标标示将接受相应更改的属性所在的实例,目标属性则用来标示接受绑定运行值的目标,而转换器则在源属性和目标属性不能直接赋值时执行转化工作。 这四部分组成之间的联动方式为:绑定源发出属性更新的通知,从而驱动绑定执行。其中源属性将作为绑定的输入,而绑定的输出则被赋予目标属性。如果绑定声明中标明了转换器,那么转换器将被执行,从而将源属性转化为合适 的目标属性。除了这些组成之外,绑定还常常使用转换器参数,绑定模式等各.. 阅读全文
posted @ 2013-05-26 17:36 若愚Shawn 阅读(510) 评论(0) 推荐(0)
摘要:Binding中使用RelativeSource问题:当前View有一个DataGrid,其DataGridTemplateColum设置了一个ComboBox。其对应的VM是local:ViewMode,含有ModelValue和myLIst属性分别用来做DataGrid的ItemSource,和ComboBox的ItemSource。外层内层看起来链接的VM层不同的property。初始代码如下:<DataGrid ItemsSource="{Binding ModelValues, Mode=TwoWay, UpdateSourceTrigger=PropertyChan 阅读全文
posted @ 2013-05-26 16:36 若愚Shawn 阅读(718) 评论(0) 推荐(0)
摘要:4 kinds of RelativeSourcemode(MSDN)Self:If you want to bind to another property on the object:{Binding Path=PathToProperty, RelativeSource={RelativeSource Self}} Imagine this case, a rectangle that we want that its height is always equal to its width, a square let's say. We can do this using the 阅读全文
posted @ 2013-05-23 18:07 若愚Shawn 阅读(390) 评论(0) 推荐(0)
摘要:http://stackoverflow.com/questions/5584948/format-date-time-in-xaml-in-silverlighthttp://matthiasshapiro.com/2010/05/28/silverlight-4-binding-and-stringformat-in-xaml/http://www.codeproject.com/Articles/195436/Formatting-text-in-Silverlight-XAML-using-StringFohttp://msdn.microsoft.com/en-us/library/ 阅读全文
posted @ 2013-05-23 16:15 若愚Shawn 阅读(170) 评论(0) 推荐(0)
摘要:创建Resource的时候我们一般在本Solution根目录下右键创建新的resource文件,is just a collection of any typed objects, not elements.比如:1 <LinearGradientBrush EndPoint="1,0" x:Key="brush1">2 <GradientStop Color="Yellow" Offset="0" />3 <GradientStop Color="Orange" 阅读全文
posted @ 2013-05-14 15:18 若愚Shawn 阅读(1117) 评论(0) 推荐(0)
摘要:Wilma项目中的例子:View Code 1 16 17 18 19 20 21 其中TargetNullValue和Binding的Path指定的后台property做对应,当后台pro... 阅读全文
posted @ 2013-05-09 16:14 若愚Shawn 阅读(613) 评论(0) 推荐(0)
摘要:http://broadcast.oreilly.com/2010/09/understanding-c-equality-iequa.html 阅读全文
posted @ 2013-05-09 09:45 若愚Shawn 阅读(155) 评论(0) 推荐(0)
摘要:赋值1:View Code 1 using System; 2 3 class ComplexNumber 4 { 5 public double Real { get; set; } 6 public double Imaginary { get; set; } 7 8 public override string ToString() 9 {10 return String.Format("{0}{1}{2}i", 11 Real, 12 Imaginary >= 0... 阅读全文
posted @ 2013-05-09 09:06 若愚Shawn 阅读(345) 评论(0) 推荐(0)
摘要:时刻提醒自己是否这个类或者方法符合SRP,我们需不需要把其分成小份的?single responsibility principle states that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.View Code 1 using System; 2 usin. 阅读全文
posted @ 2013-05-08 15:28 若愚Shawn 阅读(615) 评论(0) 推荐(0)
摘要:interface实现polymophersonView Code 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using TryCollection.Abstract; 6 7 namespace TryCollection 8 { 9 class Engine10 {11 private IState _state;12 public IState State13 {14 ... 阅读全文
posted @ 2013-05-08 10:08 若愚Shawn 阅读(217) 评论(0) 推荐(0)
摘要:Bool?属性切换不同控件方法1:换整个某个Custom的control的整个Template可以用DataTemplate的DataTrigger,用在collection里(ListView/DataGrid),特点是在Template外面,换Template例子:主要是换自定义的,用换在DT里的TemplateView Code ... 阅读全文
posted @ 2013-05-06 10:30 若愚Shawn 阅读(702) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2013-05-05 17:28 若愚Shawn 阅读(127) 评论(0) 推荐(0)