08 2011 档案

摘要:blend为我们提供方便的behavior来扩展我们的控件,写好之后就可以在blend中方便的使用了。下面是自定义的behavior来实现Listbox自动滚动到选中项其中this.AssociatedObject为使用该行为的控件。其中OnAttached()和OnDetaching()为必须重写的内容,通常可以在OnAttched()里面添加事件处理程序,来达到拓展的目的。public class AutoScrollBehavior : Behavior<ListBox> { protected override void OnAttached() { ba... 阅读全文
posted @ 2011-08-25 16:20 孤狼晖 阅读(758) 评论(0) 推荐(0) 编辑
摘要:转自:http://geekswithblogs.net/thibbard/archive/2008/02/13/wpf---get-listboxitem-from-listbox.selecteditem.aspx I had some trouble today getting the actual control that hosts data in a WPF listbox. The... 阅读全文
posted @ 2011-08-25 09:53 孤狼晖 阅读(1314) 评论(0) 推荐(0) 编辑
摘要:当我们需要操作ListBox中的ScrollerBar的时候我们可以通过VisualTreeHelper来找到。代码如下:public static childItem FindVisualChild<childItem>(DependencyObject obj) where childItem : DependencyObject{ // Search immediate childr... 阅读全文
posted @ 2011-08-24 14:28 孤狼晖 阅读(279) 评论(0) 推荐(0) 编辑
摘要:Reduce unnecessary invocations of the layout pass -- update a Transform rather than replacing itUse the most efficient Panel where possible -- don't use Grid if you need is CanvasUse Drawing which are cheaper than Shape objectsUse StreamGeometry, which is a light-weight alternative to PathGeomet 阅读全文
posted @ 2011-08-12 11:31 孤狼晖 阅读(658) 评论(0) 推荐(0) 编辑
摘要:RelayCommand : ICommand类A command whose sole purpose is to relay its functionality to otherobjects by invoking delegates. The default return value for the CanExecutemethod is 'true'. This class does not allow you to accept command parameters in theExecute and CanExecute callback methods.用来转发 阅读全文
posted @ 2011-08-12 09:01 孤狼晖 阅读(773) 评论(0) 推荐(0) 编辑
摘要:The definition of this class:The IsInDesignMode property is used to indicate whether is in the DesignMode.When we design the UI we usually use the blend ,so we need this property to bindthe view to a simple viewModel . 阅读全文
posted @ 2011-08-12 09:00 孤狼晖 阅读(490) 评论(0) 推荐(0) 编辑
摘要:当我们使用MVVM开发模式进行开发时,ViewModel之间的通信常常是很头疼的事情,好在MVVM Light提供了Messenger类可以轻松的在ViewModel之间传递消息。MessengerMessenger 其他类成员可以通过Register 方法 来建立与Messenger的联系,注册时包含当收到Message的时候要执行的方法。当使用Send方法时,注册的相关的方法将会被调用。The Messager is a class allowing objects to exchange message.主要成员:Register method ://Registers a recipi 阅读全文
posted @ 2011-08-12 08:58 孤狼晖 阅读(969) 评论(0) 推荐(1) 编辑
摘要:当我们使用依赖属性的时候,有时需要监听它的变化,这在写自定义控件的时候十分有用,下面介绍一种简单的方法。如下使用DependencyPropertyDescriptorDependencyPropertyDescriptor prop = DependencyPropertyDescriptor.FromProperty( MyType.MyDependencyProperty, typeof(M... 阅读全文
posted @ 2011-08-12 08:51 孤狼晖 阅读(704) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示