ControlTemplate Storyboard color animation problem

后端 未结 3 1690
生来不讨喜
生来不讨喜 2021-01-13 12:04

I have a problem with color animation. This is my source:

 
    

        
3条回答
  •  难免孤独
    2021-01-13 12:41

    When I came across this problem I worked around it by modifying my style to contain two identical elements on top of each other - one for the 'normal' state and one for the 'pressed' state. The 'pressed' one had its Opacity set to 0 by default and the other one had an Opacity of 1. My animation changed the opacities from 0 to 1 and vice versa.

    This approach avoided actually animating the Color property but produced the same effect whilst keeping everything in XAML. As the colours were set in the style definition rather than the animation they could be bound as required. This will probably not be suitable for all situations but for my fairly simple style it was a very quick way to achieve the desired effect.

提交回复
热议问题