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

akjoshi
  • 15,374
  • 13
  • 103
  • 121
Kent Boogaart
  • 175,602
  • 35
  • 392
  • 393

2 Answers2

2

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
  • 187,081
  • 35
  • 232
  • 306
  • 1
    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 Jul 14 '10 at 14:50
1

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
  • 175,602
  • 35
  • 392
  • 393
  • @KentBoogaart can you help with this? I need SetCurrentValue in Silverlight/WPF cross platform code http://stackoverflow.com/questions/13181788/wpf-dependency-property-precedence-reference-type-default-values#comment17945942_13181788 – Dr. Andrew Burnett-Thompson Nov 01 '12 at 20:40