XAML版本的:
<Window x:Class="StartAnimation.MainWindow" xmlns="" xmlns:x="" AllowsTransparency="True" WindowStyle="None" Title="MainWindow" Height="350" Width="525" RenderTransformOrigin=".5,.5"> <Window.RenderTransform> <ScaleTransform x:Name="scale" /> </Window.RenderTransform> <Window.Triggers> <EventTrigger RoutedEvent="Window.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="scale" From="0" To="1" Duration="00:00:01" FillBehavior="HoldEnd" AccelerationRatio=".5" /> <DoubleAnimation Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="scale" From="0" To="1" Duration="00:00:01" FillBehavior="HoldEnd" AccelerationRatio=".5" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Window.Triggers> <Border CornerRadius="6" > <Border.Background> <RadialGradientBrush Center=".5,.5" ColorInterpolationMode="ScRgbLinearInterpolation" > <GradientStop Color="Green" Offset=".2"/> <GradientStop Color="LightGreen" Offset="1"/> </RadialGradientBrush> </Border.Background> </Border> </Window> CS代码版本的: void MainWindow_Loaded(object sender, RoutedEventArgs e) { ScaleTransform transform = new ScaleTransform() { }; this.RenderTransform = transform; this.RenderTransformOrigin = new Point(.5, .5); DoubleAnimation animtion = new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(.5), FillBehavior = FillBehavior.HoldEnd, AccelerationRatio = .5 }; transform.BeginAnimation(ScaleTransform.ScaleXProperty, animtion); transform.BeginAnimation(ScaleTransform.ScaleYProperty, animtion); }