DoubleAnimation widthAnimation = new DoubleAnimation();
widthAnimation.From = 160;
widthAnimation.To = this.Width - 30;
widthAnimation.Duration = TimeSpan.FromSeconds(5);
DoubleAnimation heightAnimation = new DoubleAnimation();
heightAnimation.From = 40;
heightAnimation.To = this.Height - 50;
heightAnimation.Duration = TimeSpan.FromSeconds(5);
cmdGrow.BeginAnimation(Button.WidthProperty, widthAnimation);
cmdGrow.BeginAnimation(Button.HeightProperty, heightAnimation);
在這個示例中,兩個動畫沒有被同步。這意味著寬度和高度不會準確地在相同的時間間隔內增長(通常,將會看到按鈕先增加寬度緊接著增加高度)。可以通過創建綁定到同壹個時間線的動畫,突破這壹限制。