zoukankan      html  css  js  c++  java
  • WPF : StoryBoard用法

    Storyboard storyBoard = new Storyboard();
    DoubleAnimation ani
    = new DoubleAnimation();
               
    ani.From
    = 0;
    ani.To
    = 360;
    ani.Duration
    = new Duration(TimeSpan.FromMilliseconds(5000));
    ani.RepeatBehavior
    = RepeatBehavior.Forever;
    storyBoard.Children.Add(ani);

    this.RegisterName("mRotationX", mRotationX);
    Storyboard.SetTargetName(ani,
    "mRotationX");
    Storyboard.SetTargetProperty(ani,
    new PropertyPath(AxisAngleRotation3D.AngleProperty));
    storyBoard.Begin(
    this, true); /////true表示controlable


                TimeSpan timeSpan = TimeSpan.FromMilliseconds(250);

               
    //创建一个Animation, 设置起点, 终点, 时段
                DoubleAnimation ani = new DoubleAnimation();
                ani.From
    = 4;
                ani.To
    = 0;
                ani.Duration
    = new Duration(timeSpan);           
                Storyboard.SetTargetName(ani,
    "Opacity");
                Storyboard.SetTargetProperty(ani,
    new PropertyPath(WindowMain.OpacityProperty));

               
    //创建一个Animation, 设置起点, 终点, 时段
                DoubleAnimation ani2 = new DoubleAnimation();
                ani2.From
    = this.mZoomSlider.Value;
                ani2.To
    = 2;
                ani2.Duration
    = new Duration(timeSpan);           
                Storyboard.SetTargetName(ani2,
    "Zoom");
                Storyboard.SetTargetProperty(ani2,
    new PropertyPath(Slider.ValueProperty));


               
    //创建StoryBoard
                Storyboard storyBoard = new Storyboard();
                  storyBoard.FillBehavior = FillBehavior.Stop;
                storyBoard.Completed
    += new EventHandler(storyBoard_Completed);
                storyBoard.Children.Add(ani);
                storyBoard.Children.Add(ani2);

               
    this.RegisterName("Opacity", this);
               
    this.RegisterName("Zoom", this.mZoomSlider);           
                storyBoard.Begin(
    this, true); /////////////////////////////////true表示controlable


    或者

    <Window.Triggers>
       
    <EventTrigger RoutedEvent="Window.Loaded" >
           
    <BeginStoryboard>
               
    <Storyboard Name="myStoryBoardX">
                   
    <DoubleAnimation
            Storyboard.TargetName
    ="rotationX" 
            Storyboard.TargetProperty
    ="Angle" 
            From
    ="0" To="360" Duration="0:0:15" RepeatBehavior="Forever"/>
               
    </Storyboard>
           
    </BeginStoryboard>
           
    <BeginStoryboard>
               
    <Storyboard Name="myStoryBoardY">
                   
    <DoubleAnimation
            Storyboard.TargetName
    ="rotationY" 
            Storyboard.TargetProperty
    ="Angle" 
            From
    ="0" To="360" Duration="0:0:12" RepeatBehavior="Forever"/>
               
    </Storyboard>
           
    </BeginStoryboard>
       
    </EventTrigger>
    </Window.Triggers>
  • 相关阅读:
    Session服务器配置指南与使用经验
    关于SetLocaleInfo()
    创业及野心的一定要看
    创业公司CEO每周应该做的13件事
    NSIS 打包工具
    共勉
    Access denied for user 'root'@'localhost' (using password: NO)
    给浮躁的软件业同仁(转)
    NSIS 一点经验
    家用办公机
  • 原文地址:https://www.cnblogs.com/mrfangzheng/p/1179712.html
Copyright © 2011-2022 走看看