Start Storyboard When Text Changes

后端 未结 1 1390
无人及你
无人及你 2021-01-03 11:54

I have a TextBlock bound to a property on my view model. I have a StoryBoard with fades the text in and out using the Opacity property. I am using this text to give the user

相关标签:
1条回答
  • 2021-01-03 12:29

    Sorry, I hate to tell it to you - but you're thinking about it wrong.

    Don't think in storyboards, Opacity and Visiblity properties. Always think "Visual States".

    What you just described (fading in a TextBlock in response to some business logic change) is a perfect case for using VisualStateManager states.

    Basically you'll end up having a "Is" state group that'll have one state for when the condition is met (some state has been achieved) and another for when it's not met.

    I strongly suggest you spend 30 minutes watching these excellent Blend VSM tutorial videos. http://expression.microsoft.com/en-ca/cc643423.aspx Specifically the 7 minutes video under "Add States to a Control".

    Erwin van dar valk just published an excellent article demoing how to change VSM states from MVVM that's Pertinent to your situation. http://blogs.msdn.com/erwinvandervalk/archive/2009/10/12/how-to-work-with-animations-in-silverlight-in-the-mvvm-pattern.aspx

    0 讨论(0)
提交回复
热议问题