09 2013 档案

摘要:下图显示继承关系:ContentControl:Control (在Control類並沒有Content屬性, 所以在這之上再寫了一個ContentControl, 使控件有Content屬性可以顯示內容)ContentPresenter:FrameworkElement (ContentPresenter一般用在CT里负责把Control指定的Content显示出来)Control:FrameworkElementItemsControl:ControlItemsPresenter:FrameworkElement接著來我們看一下實例:使用ContentPresenter ... 阅读全文
posted @ 2013-09-30 11:13 若愚Shawn 阅读(3970) 评论(0) 推荐(1)
摘要:Routing Strategies:DirectBubblingTunnelingWHy use them?Any UIElement can be a listenerCommon handlersVisual Tree CommunicationEvent Setter and Event TriggerRouted Event Example: //listen to the RoutedEvent:ButtonBase.Click and handle RoutedEvent using Window_Click //listen to the Rou... 阅读全文
posted @ 2013-09-27 13:20 若愚Shawn 阅读(252) 评论(0) 推荐(0)
摘要:I. Binding to Object1. Binding data using ObjectDataProviderAC:Let’s say there is a CLR based data bound object that you are trying to implement. For example a collection of Tool objects, e.g.An Object called Tool that contains a bunch of properties that we want to bind (in this case it just contain 阅读全文
posted @ 2013-09-20 12:01 若愚Shawn 阅读(460) 评论(0) 推荐(0)
摘要:DataTemplate和ControlTemplate的关系(转载自haiziguo)一、ContentControl中的DataTemplate在开始之前,我们先去看一下ContentControl的定义,有两个属性: public object Content { get; set; } public DataTemplate ContentTemplate { get; set; }其特点是只能容纳一个内容,内容类型是object类型,其中Button控件是我们大家比较熟悉且属于ContentControl的类,这里用TextBlock做Content。这个很正常,因为内容是o... 阅读全文
posted @ 2013-09-20 08:29 若愚Shawn 阅读(498) 评论(0) 推荐(0)
摘要:using System;using System.ComponentModel;using System.Globalization;using System.Windows.Data;namespace WPFComponents{ [ValueConversion(typeof(string), typeof(int))] public class StringToIntegerConverter : IValueConverter { public object Convert(object value, Type targetType, ... 阅读全文
posted @ 2013-09-19 14:57 若愚Shawn 阅读(557) 评论(0) 推荐(0)
摘要:如何拿到Source:从SQL,从XML fileSQL:一个是ObjectDataProvider//用linq方法拿到SQL data,wrap到一个IEnumerablepublic IEnumerable GetAllCustomersAsList() { var items = from cust in this.Customers orderby cust.LastName select cust; return items.ToList(); }View Code //xaml里定... 阅读全文
posted @ 2013-09-19 13:44 若愚Shawn 阅读(251) 评论(0) 推荐(0)
摘要:1:做Icon用Canvas还是DrawingBrush?Canvas的例子: ... 阅读全文
posted @ 2013-09-16 20:16 若愚Shawn 阅读(307) 评论(0) 推荐(0)
摘要:Limited functionality:Not settableNo data bindingNo validationNo animationNo InheritanceWhen to use?Used for state determination(Defined the style for the control, some visiable property like fore/background will change when mouse movehover)Used as a property trigger(由这个readonly property change,来cha 阅读全文
posted @ 2013-09-09 14:00 若愚Shawn 阅读(366) 评论(0) 推荐(0)
摘要:我有一个TabControl View Code 要实现上面的Behivor需要设计其trigger。方法一:设置一个trigger和一个MultiTrigger,其实不用写方法二:设置一个Trigger和一个DataTrigger说明的三点问题:MultiDataTrigger里... 阅读全文
posted @ 2013-09-09 10:28 若愚Shawn 阅读(297) 评论(0) 推荐(0)
摘要:简单的DP注册:注意:Wrapper里的get,set永远不要写任何逻辑或者.Net提供的方法Text Wrapper只是一个helper,里面的get set永远不会被程序call到,breakpoint进不去。唯一可以进入set是直接对这个CLR property赋值。DP register的时候可以指定PropertyMetadata或者FrameworkPropertyMetadataPropertyMetadata:Specify default valuescoercionproperty change callbacksvalidation从上面简单DP register变过来的 阅读全文
posted @ 2013-09-06 14:12 若愚Shawn 阅读(131) 评论(0) 推荐(0)
摘要:1:binding后台bool[]数据以及后台ObservableCollection数据分别见下面xaml的Visibility和Text的Bindingpublic bool[] RubberTypeLegends { get { bool[] result = new bool[] {false,false,false }; for (int i = 0; i ...private O... 阅读全文
posted @ 2013-09-06 11:14 若愚Shawn 阅读(304) 评论(0) 推荐(0)
摘要:Case ID (?unit)红色的字根据一个后台boolean来做trigger,可以是Case or Open蓝色的字binding到后台的一个string属性来切换任意的Unit单位这样一共有6中组合:Case ID (in) OpenID (in)Case ID (cm) OpenID (cm)Case ID (mm) OpenID (mm)上图两个红圈的字分别控制显示那个Text代码如下: ... 阅读全文
posted @ 2013-09-05 10:43 若愚Shawn 阅读(381) 评论(0) 推荐(0)
摘要:http://msdn.microsoft.com/en-us/magazine/cc163299.aspx#S1Data Binding in WPFJohn PapaCode download available at:DataPoints2007_12.exe(161 KB) Contents Data Binding SpecificsCreating a Simple BindingBinding ModesA Time to BindBinding to XMLObject Binding and DataTemplatesSorting the DataForging Ahea. 阅读全文
posted @ 2013-09-03 08:35 若愚Shawn 阅读(730) 评论(0) 推荐(0)