views:

40

answers:

2

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  A: 

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.

AnthonyWJones
Just tried this and am surprised to report it seems to work. I'm surprised because it's an animation so I assumed the low precedence would cause issues. I will certainly stick with this solution if I can because it's less code. Thanks.
Kent Boogaart
A: 

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

Kent Boogaart