延迟属性上从.net 4.5在.NET 4.0中绑定 [英] Delay property on Binding from .Net 4.5 in .Net 4.0
问题描述
如何实现从.net 4.5延迟性(说明<一href="http://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.delay%28v=vs.110%29.aspx">here)在.NET 4.0中绑定?
How can I implement Delay property from .Net 4.5 (described here) on binding in .Net 4.0?
我知道我不能从BindingBase继承的ProvideValue是密封的。
I know I cannot inherit from BindingBase as ProvideValue is sealed.
我可以实现的MarkupExtension但它意味着我现在不得不重写从BindingExtension所有属性是有没有其他办法?
I could implement MarkupExtension but it means I now have to rewrite all properties from BindingExtension is there any other way?
推荐答案
我想创建一个 AttachedProperty
指定的时间延时量。该 AttachedProperty
将开始(或复位)定时器,当绑定值的变化,并且将手动更新时的指定时间到达被绑定的源。
I would create an AttachedProperty
that specifies the amount of time to Delay. The AttachedProperty
would start (or reset) a timer when the bound value changes, and would manually update the bound source when the specified amount of time gets reached.
您可以使用下面的更新源绑定:
You can use the following to update the source binding:
BindingOperations.GetBindingExpressionBase(
dependencyObject, dependencyProperty).UpdateSource();
修改
我今天改bug在一些老code,发现它使用附加的行为实施的延迟属性更改通知。我想到了这个问题,所以跟着我曾评论说,在code的连接,并发现自己在一个问题我已经发布了一段时间前就SO有关的延迟绑定。最多的回答就是我目前已经实现了,这是一些附加属性,更新的在X毫秒已通过绑定的来源。
I was fixing a bug in some old code today and noticed it implemented a delayed property change notification using an Attached Behavior. I thought of this question, so followed the link that I had commented in the code, and found myself at a question I had posted a while ago on SO about delaying a binding. The top answer is the one I have implemented currently, which is some attached properties that updates the source of a binding after X milliseconds have passed.
这篇关于延迟属性上从.net 4.5在.NET 4.0中绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!