Comment animer un Point en WPF ?

  • -
Question de Cortex240 vues – Il y a 2 ans dans Programmation
Selon l'auteur cette réponse semble la plus pertinente

Pour animer un Point en WPF il faut créer un Storyboard qui anime ce point via des PointAnimation.

Exemple de PointAnimation en C# 

PointAnimation myPointAnimation = new PointAnimation();myPointAnimation.Duration = TimeSpan.FromSeconds(2);myPointAnimation.RepeatBehavior = RepeatBehavior.Forever;myPointAnimation.From = new Point(200, 100);myPointAnimation.To = new Point(450, 250);Storyboard.SetTargetName(myPointAnimation, "MyAnimatedEllipseGeometry");Storyboard.SetTargetProperty( myPointAnimation, new PropertyPath(EllipseGeometry.CenterProperty));Storyboard ellipseStoryboard = new Storyboard(); ellipseStoryboard.Children.Add(myPointAnimation);

Exemple de PointAnimation en XAML

<Storyboard><PointAnimation Storyboard.TargetProperty="Center" Storyboard.TargetName="MyAnimatedEllipseGeometry" Duration="0:0:2" From="200,100" To="450,250" RepeatBehavior="Forever" /> </Storyboard>

Réponse de Cortex, surnommé L'exhibitioniste  Niveau 4
Il y a 2 ans

0 pts