J'ai besoin d'animer plusieurs propriétés d'un élément d'interface utilisateur en même temps. Par exemple, réduire la largeur et la hauteur des fenêtres de manière synchrone. Par exemple:Animation WPF (modification simultanée de plusieurs propriétés d'un seul élément)
Une idée?
DoubleAnimation widthAnimation = new DoubleAnimation
{
To = 0,
Duration = TimeSpan.FromSeconds(5)
};
DoubleAnimation heightAnimation = new DoubleAnimation
{
To = 0,
Duration = TimeSpan.FromSeconds(5)
};
Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(Window.WidthProperty));
Storyboard.SetTarget(widthAnimation, this);
Storyboard.SetTargetProperty(heightAnimation, new PropertyPath(Window.HeightProperty));
Storyboard.SetTarget(heightAnimation, this);
Storyboard s = new Storyboard();
s.Completed += FadeOut_Completed;
s.Children.Add(widthAnimation);
s.Children.Add(heightAnimation);
this.BeginStoryboard(s, HandoffBehavior.SnapshotAndReplace, true);
Il fera des animations étape par étape; la hauteur changera après que les changements de largeur soient terminés! : |
Il n'y a rien de mal avec votre code, pourriez-vous poster un échantillon de travail qui peut reproduire le même problème? – pushpraj
c'est le projet exemple https://drive.google.com/file/d/0B9V5dv1Y3m0MQ0pBdXlqQlFjdWs/edit?usp=sharing – Matrix