我想用它,但它doesnt't的工作,我想創建一個瓷磚的動畫,在後面的代碼,或者如果你知道這個GOL項目,請給我寫如何使用故事板爲Stackpanel的邊距添加動畫?
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
while(true){
Duration duration = new Duration(TimeSpan.FromSeconds(0.15));
// Create two DoubleAnimations and set their properties.
DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
myDoubleAnimation1.Duration = duration;
myDoubleAnimation1.From = -173
myDoubleAnimation1.To = 173;
Storyboard sb = new Storyboard();
sb.Duration = duration;
sb.Children.Add(myDoubleAnimation1);
Storyboard.SetTarget(myDoubleAnimation1, image);
// Set the attached properties of Canvas.Left and Canvas.Top
// to be the target properties of the two respective DoubleAnimations.
Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath(StackPanel.MarginProperty));
// Begin the animation.
sb.Begin();}
});
邊距的類型是厚度 - 不是雙倍(這是使用雙動畫的原因)。您需要動畫Margin屬性的內容,這是一個結構,我不知道您是否可以這樣做。你想做什麼。 – 2012-04-16 20:32:28
您是否真的在Storyboard之後的無限循環中創建Storyboard? – Clemens 2012-04-16 20:34:59
可能重複[Animating Margin Bottom Silverlight](http://stackoverflow.com/questions/6507954/animating-margin-bottom-silverlight) – ColinE 2012-04-16 20:39:10