blinking in my wpf transition animation

319 views Asked by At

I'm trying to achieve a custom transition animation with a shadereffect on an image. I'm using a system i made for specifying easing Bézier functions graphicaly and i process all the spline data in a class called Spline.

i'm animating a time property send to a Spline's static method to compute the Bézier data for easing. then i get the computed value that i send to the Time property of my shader effect but i can't use beginAnimation on this transition because the class playing the animation is a non-UI one and already inheriting from an abstract class.

If i want to use beginAnimation, i have to make the abstract class inherit from dependencyObject to use a dependency property as parameter of BeginAnimation but i get this error

this.BeginAnimation(TimeProperty, anim);


'MyClass' doesn't contain a definition for BeginAnimation and no extension method BeginAnimation accepting a frist argument of type 'MyClass' could be found (are you missing a using directive or an assembly reference)

all this dependency/Animatable system doesn't fit my needs since i'm not working on the ui directly and i'm totally stuck now

Any idea?

(I used a dispatcherTimer to do the trick but when the animation finish, i can see the background color of my application during half a second and then my second image finally shows up but i don't want this behavior since it will be marketed...)

2

There are 2 answers

0
Julien On BEST ANSWER

I finally used a Storyboard to achieve this, using the Dependency object inheritance on my abstract class.

And even if it's not great to use the Sotryboard/dependencyProperty system on a non-UI object(in my opinion), it works.

I have a storyboard to animate a DependencyProperty named Time in MyClass from 0 to 1. In the PropertyChangedCallback of Time, i compute my new time value depending on my custom spline easing function, and then affect it to the Progress property of my Shader.

thanks for concern anyway.

2
Florian On

Use a KeyFrame Animation. You can add single Frames to it. As example you can hide something every 2nd keyframe.