var storyboard = new Storyboard();
Storyboard.SetTarget(storyboard, grid);
Storyboard.SetTargetProperty(storyboard, new PropertyPath(Grid.OpacityProperty));
var OpacityDoubleAnimation = new DoubleAnimation();
OpacityDoubleAnimation.From = 0;
OpacityDoubleAnimation.To = 1;
OpacityDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
storyboard.Children.Add(OpacityDoubleAnimation);
storyboard.Begin();
TransformGroup group = new TransformGroup();
RotateTransform rtf = new RotateTransform();
group.Children.Add(rtf);
ScaleTransform rtf2 = new ScaleTransform();
group.Children.Add(rtf2);
grid.RenderTransform = group;
Storyboard.SetTargetProperty(storyboard, new PropertyPath("RenderTransform.Children[0].Angle"));
DoubleAnimation dbAscending = new DoubleAnimation(70, 0, new Duration(TimeSpan.FromSeconds(1)));
storyboard.Children.Add(dbAscending);
storyboard.Begin();
Storyboard.SetTargetProperty(storyboard, new PropertyPath("RenderTransform.Children[1].ScaleX"));
DoubleAnimation dbAscending2 = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(1)));
dbAscending2.AccelerationRatio = 1;
storyboard.Children.Add(dbAscending2);
storyboard.Begin();
Storyboard.SetTargetProperty(storyboard, new PropertyPath("RenderTransform.Children[1].ScaleY"));
DoubleAnimation dbAscending3 = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(1)));
dbAscending3.AccelerationRatio = 1;
storyboard.Children.Add(dbAscending3);
storyboard.Begin();
Storyboard.SetTargetProperty(storyboard, new PropertyPath("RenderTransform.Children[1].ScaleX"));
DoubleAnimation dbAscending4 = new DoubleAnimation();
dbAscending4.Duration = new Duration(TimeSpan.FromSeconds(0.05));
dbAscending4.BeginTime = TimeSpan.FromSeconds(1);
dbAscending4.To = 0.98;
dbAscending4.AccelerationRatio = 1;
storyboard.Children.Add(dbAscending4);
storyboard.Begin();
Storyboard.SetTargetProperty(storyboard, new PropertyPath("RenderTransform.Children[1].ScaleY"));
DoubleAnimation dbAscending5 = new DoubleAnimation();
dbAscending5.Duration = new Duration(TimeSpan.FromSeconds(0.05));
dbAscending5.BeginTime = TimeSpan.FromSeconds(1);
dbAscending5.To = 0.98;
dbAscending5.AccelerationRatio = 1;
storyboard.Children.Add(dbAscending5);
storyboard.Begin();
Storyboard.SetTargetProperty(storyboard, new PropertyPath("RenderTransform.Children[1].ScaleX"));
DoubleAnimation dbAscending6 = new DoubleAnimation();
dbAscending6.Duration = new Duration(TimeSpan.FromSeconds(0.2));
dbAscending6.BeginTime = TimeSpan.FromSeconds(1.05);
dbAscending6.To = 1;
dbAscending6.AccelerationRatio = 1;
storyboard.Children.Add(dbAscending6);
storyboard.Begin();
Storyboard.SetTargetProperty(storyboard, new PropertyPath("RenderTransform.Children[1].ScaleY"));
DoubleAnimation dbAscending7 = new DoubleAnimation();
dbAscending7.Duration = new Duration(TimeSpan.FromSeconds(0.2));
dbAscending7.BeginTime = TimeSpan.FromSeconds(1.05);
dbAscending7.To = 1;
dbAscending7.AccelerationRatio = 1;
storyboard.Children.Add(dbAscending7);
storyboard.Begin();
与下效果一样
<BeginStoryboard>
<Storyboard SpeedRatio="1.5">
<DoubleAnimation Storyboard.TargetName="element"
Storyboard.TargetProperty="Opacity"
From="0.2" To="1" Duration="0:0:2.5"></DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="element"
Storyboard.TargetProperty="RenderTransform.Children[1].Angle"
From="70" To="0" Duration="0:0:2" ></DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="element"
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX"
From="0" To="1" Duration="0:0:2" AccelerationRatio="1"></DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="element"
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY"
From="0" To="1" Duration="0:0:2" AccelerationRatio="1"></DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="element"
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX"
To="0.98" BeginTime="0:0:2" Duration="0:0:0.05" DecelerationRatio="1"></DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="element"
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY"
To="0.98" BeginTime="0:0:2" Duration="0:0:0.05" DecelerationRatio="1"></DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="element"
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX"
To="1" BeginTime="0:0:2.05" Duration="0:0:0.2" AccelerationRatio="1"></DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="element"
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY"
To="1" BeginTime="0:0:2.05" Duration="0:0:0.2" AccelerationRatio="1"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
<Grid>
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform></ScaleTransform>
<RotateTransform></RotateTransform>
</TransformGroup>
</Grid.RenderTransform>
</Grid>
//这条是TranslateTransform.XProperty
var storyboard = new Storyboard(); Storyboard.SetTarget(storyboard, popupgrid); TranslateTransform rtf = new TranslateTransform();
Storyboard.SetTargetProperty(storyboard, new PropertyPath(TranslateTransform.XProperty));popupgrid.RenderTransform = rtf;
DoubleAnimation dbAscending2 = new DoubleAnimation(0, 100, new Duration(TimeSpan.FromSeconds(2)));
dbAscending2.AccelerationRatio = 1;
storyboard.Children.Add(dbAscending2);
storyboard.Begin();