原文:WPF 扩大,回弹效果
<Window x:Class="Fish.AccountBook.View.Test.PanelWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PanelWindow" Height="300" Width="500">
<Grid>
<Rectangle Name="rectangle1" Height="104"
HorizontalAlignment="Left"
Margin="68,78,0,0" Stroke="Black"
VerticalAlignment="Top" Width="158"
RenderTransformOrigin="0.5,0.5" >
<Rectangle.RenderTransform>
<ScaleTransform x:Name="m_Scale" ScaleX="0.1" ScaleY="0.1" />
</Rectangle.RenderTransform>
</Rectangle>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="312,157,0,0" Name="button1" VerticalAlignment="Top" Width="75">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="m_Scale"
Storyboard.TargetProperty="ScaleX"
From="0.1" To="1" Duration="0:0:1">
<DoubleAnimation.EasingFunction>
<ElasticEase EasingMode="EaseOut" Oscillations="2" Springiness="4" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation
Storyboard.TargetName="m_Scale"
Storyboard.TargetProperty="ScaleY"
From="0.1" To="1" Duration="0:0:1" >
<DoubleAnimation.EasingFunction>
<ElasticEase EasingMode="EaseOut" Oscillations="2" Springiness="4" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</Grid>
</Window>
CS:
EasingFunctionBase easing = new ElasticEase()
{
EasingMode = EasingMode.EaseOut,
Oscillations = ,
Springiness =
}; DoubleAnimation inAnimation = new DoubleAnimation()
{
From = 0.1,
To = ,
EasingFunction = easing,
Duration = new Duration(TimeSpan.FromSeconds())
}; AnimationClock clock = inAnimation.CreateClock();
this.m_Scale.ApplyAnimationClock(ScaleTransform.ScaleXProperty, clock);
this.m_Scale.ApplyAnimationClock(ScaleTransform.ScaleYProperty, clock);