zoukankan      html  css  js  c++  java
  • 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();

            }

        }

  • 相关阅读:
    详解 exception
    如何转换音频数据格式1
    解说一个简单的Win32程序
    java通过jxl.jar实现excel导入导出
    linux2.6.32在mini2440开发板上移植(8)之添加ADC驱动程序
    Hut 1997 Seven tombs
    python help dir stackoverflow docs google遇到python问题怎么样解决
    802.11n兼容a/b/g问题(Legacy mode,Mixed mode,Greenfield mode)
    gperf的使用
    ubuntu terminal 关闭防火墙
  • 原文地址:https://www.cnblogs.com/bruce1992/p/14222270.html
Copyright © 2011-2022 走看看