daixinet

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
<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 = 5,
                Springiness = 10
            };

            DoubleAnimation inAnimation = new DoubleAnimation()
            {
                From = 0.1,
                To = 1,
                EasingFunction = easing,
                Duration = new Duration(TimeSpan.FromSeconds(5))
            };

            AnimationClock clock = inAnimation.CreateClock();
            this.m_Scale.ApplyAnimationClock(ScaleTransform.ScaleXProperty, clock);
            this.m_Scale.ApplyAnimationClock(ScaleTransform.ScaleYProperty, clock);

 

 

 

posted on 2012-06-05 00:17  daixinet.com  阅读(1346)  评论(0编辑  收藏  举报