Using TemplateBinding in ObjectAnimationUsingKeyFrames

后端 未结 2 1015
不思量自难忘°
不思量自难忘° 2021-01-24 05:52

I try to set the background color of a control when mouse is over it. I try to do it via the visual state manager. I was able to get the following code running:

         


        
相关标签:
2条回答
  • 2021-01-24 06:15

    Unfortunately the way you're trying to do it won't work in Silverlight. The VisualStateManager animations are not part of the display tree, so you can't use binding. You have options though, StaticResources (aka setting up colours in the resource dictionary) and code based animations are different workarounds (depending on exactly what you want to do). For the latter check out a thread where I asked a similar question: How can I animate a property dynamically in a Silverlight 4 UserControl?

    0 讨论(0)
  • 2021-01-24 06:16

    You cannot do it dynamically on a single target, but what you can do is create another target (for example called BorderBackgroundAlt) whose background you can explicitly set to {TemplateBinding Tag} in its declaration.

    Then you can have BorderBackgroundAlt collapsed by default, and in your animation frame instead of switching colors, switch visibilities, such that BorderBackground is collapsed and BorderBackgroundAlt is visible.

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