#778 – 缩放变换动画(Animating a Scale Transform)

原文地址:https://wpf.2000things.com/2013/03/18/778-animating-a-scale-transform/

下面是一个2D的缩放变换动画的例子。在这个例子中按钮会重复的变大变小抖动。

<Grid>
    <Button Content="Ship via Wells, Fargo & Co." HorizontalAlignment="Center" VerticalAlignment="Center"
            Padding="20,10" FontSize="16"
            RenderTransformOrigin="0.5,0.5">
        <Button.RenderTransform>
            <ScaleTransform x:Name="scaleTransform" ScaleX="0.98" ScaleY="1.02"/>
        </Button.RenderTransform>
        <Button.Triggers>
            <EventTrigger RoutedEvent="Button.Loaded">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="scaleTransform"
                                         Storyboard.TargetProperty="ScaleX"
                                         From="0.98" To="1.02" Duration="0:0:0.3"
                                         AutoReverse="True" RepeatBehavior="Forever"/>
                        <DoubleAnimation Storyboard.TargetName="scaleTransform"
                                         Storyboard.TargetProperty="ScaleY"
                                         From="0.98" To="1.02" Duration="0:0:0.3"
                                         AutoReverse="True" RepeatBehavior="Forever"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Button.Triggers>
    </Button>
</Grid>
 




阅读更多
个人分类: WPF
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭