Silverlight DependencyProperty.SetCurrentValue 等效项
我正在寻找相当于 .NET 4 的 SL4 SetCurrentValue API,这似乎正是我的场景所需要的。
简而言之,我正在编写一个附加行为,它会在适当的时间更新给定属性的值。但是,我不希望它覆盖在该依赖项属性上设置的任何绑定。我只想将该值推送到属性(因此可以根据该值刷新任何绑定)。
据我所知,在 SL4 中还没有简单的方法可以做到这一点。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Silverlight 不提供对此级别的依赖值的直接访问。然而,故事板中的动画在操作属性时设置的正是这个级别的值。
因此,包含单个
DiscreteObjectKeyFrame
的持续时间长度为 0 的 Storyboard 可能会达到您想要的结果。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.我已经通过检测绑定并在源和目标之间注入代理对象来模拟我所追求的内容。然后我可以操纵代理并刷新原始绑定的两侧。
它很丑陋,而且比我想要的还要多,但它似乎有效。
肯特
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