个人资料

主页 博客 留言板 搜索
跳过导航链接首页 > 博客列表 > 博客正文

UWP/WPF使用XAML设置UI元素简单的动画

分类

以Image为例,使用Xaml语法进行设置。

<img x:name="MapPinImage" source="ms-appx:///Assets/mappin.png" width="50" height="50" rendertransformorigin="0.5,0.5" />
<image.rendertransform>
    <compositetransform x:name="PinAnimation" translatey="0" scalex="1" scaley="1"></compositetransform>
</image.rendertransform>
<image.triggers>
    <eventtrigger routedevent="Image.Loaded">
        <beginstoryboard x:name="bs_pin">
            <storyboard x:name="sb_pin" repeatbehavior="Forever">
                <doubleanimation storyboard.targetname="PinAnimation" storyboard.targetproperty="TranslateY" from="0" to="-0.1" duration="0:0:0.5" autoreverse="True"></doubleanimation>
                <doubleanimation storyboard.targetname="PinAnimation" storyboard.targetproperty="ScaleX" from="1" to="1.1" duration="0:0:0.5" autoreverse="True"></doubleanimation>
                <doubleanimation storyboard.targetname="PinAnimation" storyboard.targetproperty="ScaleY" from="1" to="1.1" duration="0:0:0.5" autoreverse="True"></doubleanimation>
            </storyboard>
        </beginstoryboard>
    </eventtrigger>
</image.triggers>

songshizhao
最初发表2018/9/8 2:20:53 最近更新2018/9/8 2:20:53 222
为此篇作品打分
10