• uwp 中的动画


    xml

    ---------------------------------------

    <Page

        x:Class="MyApp.MainPage"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:local="using:MyApp"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        mc:Ignorable="d"

        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <Grid>

            <Path HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" Height="300" Stretch="Uniform" Fill="Yellow" RenderTransformOrigin="0.5,0.5">

                <Path.Data>

                    <GeometryGroup>

                        <EllipseGeometry Center="50,50" RadiusX="50" RadiusY="20"/>

                        <EllipseGeometry Center="50,50" RadiusX="20" RadiusY="50"/>

                    </GeometryGroup>

                </Path.Data>

                <Path.RenderTransform>

                    <RotateTransform x:Name="rttrf" Angle="0"/>

                </Path.RenderTransform>

            </Path>

        </Grid>

    </Page>

    C# code

    -------------------------------------------

      public sealed partial class MainPage : Page

        {

            Storyboard m_storyboard = null;

            public MainPage()

            {

                this.InitializeComponent();

                this.NavigationCacheMode = NavigationCacheMode.Required;

                // 初始化演示图板

                m_storyboard = new Storyboard();

                // 定义时间线

                DoubleAnimation da = new DoubleAnimation();

                da.Duration = TimeSpan.FromSeconds(2d); //时间线持续时间

                da.From = 0d; //初始值

                da.To = 360d; //最终值

                // 设置为无限循环播放

                da.RepeatBehavior = RepeatBehavior.Forever;

                // 将时间线与RotateTransform对象关联

                Storyboard.SetTarget(da, rttrf);

                Storyboard.SetTargetProperty(da, "Angle");

                // 将时间线加入Storyboard的时间线集合中

                m_storyboard.Children.Add(da);

            }

            protected override void OnNavigatedTo(NavigationEventArgs e)

            {

                // 开始播放动画

                m_storyboard.Begin();

            }

        }

  • 相关阅读:
    Informatica_(6)性能调优
    Informatica_(5)高级应用
    Informatica_(4)工作流
    Informatica_(3)组件
    Informatica_(2)第一个例子
    Informatica_(1)安装
    Linux_(4)Shell编程(下)
    Linux_(3)Shell编程(上)
    Linux_(2)基本命令(下)
    B
  • 原文地址:https://www.cnblogs.com/bruce1992/p/14222270.html
Copyright © 2020-2023  润新知