When ObjectAnimationUsingKeyFrames tries to animate the value obtained from DependencyObject , it tries to freeze the object first. If the object cannot be frozen, it throws an exception and the animation does not start.
If you are animating a custom type value that you wrote, it seems that you need to either deduce from Freezable or not deduce from DependencyObject .
For existing properties derived from DependencyObject , not Freezable , you cannot animate them ( StyleProperty or TemplateProperty are examples). Try using the setter property inside the style:
<Style.Triggers> <Trigger Property="IsEnabled" Value="True"> <Setter Property="Template" Value="{StaticResource TestTemplate}"/> </Trigger> </Style.Triggers>
Build all the transition logic in a style instead of switching between different styles. The problem you can have with this is that the target property must be a dependency property, so you cannot use IsLoaded .
I hope you find this helpful.
Last thought: you can define custom animations , although I myself did not. There is an external chance that you can write your own "ObjectAnimation", which will not be limited to Freezable or DependencyObject classes.
Josh g
source share