2013-02-05 41 views
0

需要改變電網興致勃勃形式C#的大小,我知道從動畫是最好的,但不知道如何做到這一點,也表明了更好的方式,如果可用爲了從動畫改變網格尺寸

+0

你有什麼或者你嘗試過什麼到目前爲止.. – MethodMan

+0

你的意思是你要設置使用要和從值範圍網格的大小? –

+0

@DJ KRAZE - 正如我前面提到的「我不知道從C#創建動畫」,直到我還沒有使用動畫故事板(在Silverlight中)動畫 – Faizan

回答

0

得到它在MSDN

// Create a red rectangle that will be the target 
Rectangle myRectangle = new Rectangle(); 
myRectangle.Width = 200; 
myRectangle.Height = 200; 
Color myColor = Color.FromArgb(255, 255, 0, 0); 
SolidColorBrush myBrush = new SolidColorBrush(); 
myBrush.Color = myColor; 
myRectangle.Fill = myBrush; 

// Add the rectangle to the tree. 
LayoutRoot.Children.Add(myRectangle); 

// Create a duration of 2 seconds. 
Duration duration = new Duration(TimeSpan.FromSeconds(2)); 

// Create two DoubleAnimations and set their properties. 
DoubleAnimation myDoubleAnimation1 = new DoubleAnimation(); 
DoubleAnimation myDoubleAnimation2 = new DoubleAnimation(); 

myDoubleAnimation1.Duration = duration; 
myDoubleAnimation2.Duration = duration; 

Storyboard sb = new Storyboard(); 
sb.Duration = duration; 

sb.Children.Add(myDoubleAnimation1); 
sb.Children.Add(myDoubleAnimation2); 

Storyboard.SetTarget(myDoubleAnimation1, myRectangle); 
Storyboard.SetTarget(myDoubleAnimation2, myRectangle); 

// 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("(Canvas.Left)")); 
Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(Canvas.Top)")); 

myDoubleAnimation1.To = 200; 
myDoubleAnimation2.To = 200; 

// Make the Storyboard a resource. 
LayoutRoot.Resources.Add("unique_id", sb); 

// Begin the animation. 
sb.Begin(); 
+0

只需將不透明度的目標屬性更改爲大小即可 – Faizan