摘要: WPF自动定义控件一般有三种方式:第一种是建立一个UserControl,这是最简单的方式,也是比较常用的方式。在这种方式中,可以直接使用VS的设计器进行UI的设计,并且可以直接添加事件处理函数,还可以为它设计对应的ViewMode。与一般的Window的设计没什么区别。第二种是继承自Control类,这也是一种比较常用的方式。这种方式需要提供一个默认的ControlTemplate,并且使用该控件的开发者,可以为该控件提供新的ControlTemplate和DataTemplate。第三种是继承自FrameWorkElement,这种方式是比较底层的设计新的UserControl的方法。需要 阅读全文
posted @ 2013-08-31 00:10 AndrewYu 阅读(4976) 评论(1) 推荐(0) 编辑
摘要: 以下方法只能实现一次绑定,如果MyVisible属性在ViewModel中被修改的话,不会影响DataGrid的Column的显示或者隐藏后台代码publicpartialclassMainWindow:Window,INotifyPropertyChanged{publicMainWindow(){InitializeComponent();this.DataContext=this;} privateIListmockData;publicIListMockData{get{if(mockData==null){mockData=newList();mockData.Add(newData 阅读全文
posted @ 2013-07-24 22:21 AndrewYu 阅读(1096) 评论(0) 推荐(0) 编辑
摘要: //////publicstaticclassExtensionMethods{publicstaticvoidExpandAll(thisSystem.Windows.Controls.TreeViewtreeView){ExpandAllItems(treeView);} privatestaticvoidExpandAllItems(ItemsControlcontrol){if(control==null){return;} foreach(Objectitemincontrol.Items){System.Windows.Controls.TreeViewItemtreeItem=c 阅读全文
posted @ 2013-07-22 22:04 AndrewYu 阅读(748) 评论(0) 推荐(0) 编辑
摘要: 在.Net中有以下几种TimerSystem.Windows.Forms.TimerSystem.Timers.TimerSystem.Threading.TimerSystem.Windows.Threading.DispatcherTimerSystem.Windows.Forms.Timer ... 阅读全文
posted @ 2012-02-04 14:00 AndrewYu 阅读(431) 评论(0) 推荐(0) 编辑