Silverlight DependencyProperty.SetCurrentValue Equivalent

谁都会走 提交于 2019-12-24 03:19:30

问题


I'm looking for a SL4 equivalent to .NET 4's SetCurrentValue API, which would appear to be exactly what I need for my scenario.

In short, I'm writing an attached behavior that updates the value of a given property at appropriate times. However, I don't want it to overwrite any bindings that are set on that dependency property. I merely want to push that value to the property (and therefore have any bindings refresh based on that value).

From what I can tell, there's no easy way to do this yet in SL4.

Thanks


回答1:


Silverlight does not provide direct access to this level of dependency value. However its this level of value that Animations in storyboards set when they manipulate a property.

Hence a Storyboard with a 0 length duration containing a single DiscreteObjectKeyFrame might achieve your desired result.




回答2:


I've managed to simulate what I'm after by detecting bindings and injecting a surrogate object between the source and target. I can then manipulate the surrogate and have both sides of the original binding refresh.

It's ugly and more work than I'd like, but it seems to work.

Kent



来源:https://stackoverflow.com/questions/3247008/silverlight-dependencyproperty-setcurrentvalue-equivalent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!