zoukankan      html  css  js  c++  java
  • WP7备注(36)(动画)

    使用代码来配置UIElement的Animation:

    void OnButtonClick(object sender, RoutedEventArgs args)
    {
    Button btn = sender as Button;
    RotateTransform rotateTransform = btn.RenderTransform as RotateTransform;
    // Create and define animation
    DoubleAnimation anima = new DoubleAnimation();
    anima.From = 0;
    anima.To = 360;
    anima.Duration = new Duration(TimeSpan.FromSeconds(0.5));
    // Set attached properties
    Storyboard.SetTarget(anima, rotateTransform);
    Storyboard.SetTargetProperty(anima, new
    PropertyPath(RotateTransform.AngleProperty));
    // Create storyboard, add animation, and fire it up!
    Storyboard storyboard = new Storyboard();
    storyboard.Children.Add(anima);
    storyboard.Begin();
    }

    对于特定属性的Target设置:

    Storyboard.SetTargetProperty(anima,
    new PropertyPath("(Button.RenderTransform).(RotateTransform.Angle)"));

    Animation的其他配置:

    anima.RepeatBehavior = new RepeatBehavior(3);
    anima.AutoReverse = true;
    anima.FillBehavior = FillBehavior.HoldEnd;

    XAML-Base的Animation:

    <Storyboard x:Name="storyboard">
    <DoubleAnimation Storyboard.TargetName="rotate"
    Storyboard.TargetProperty="Angle"
    From="0" To="360" Duration="0:0:0.5" />
    </Storyboard>

    另一种写法:

    <DoubleAnimation Storyboard.TargetName="btn"
    Storyboard.TargetProperty="(Button.RenderTransform).(RotateTransform.Angle)"
    From="0" To="360" Duration="0:0:0.5" />

    对于文本,有个特别的设置:TextOptions.TextHintingMode="Animated"

    KeyFrames:

    <Storyboard x:Name="jiggleStoryboard">
    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="translate"
    Storyboard.TargetProperty="X"
    RepeatBehavior="3x">
    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="0" />
    <LinearDoubleKeyFrame KeyTime="0:0:01" Value="-100" />
    <LinearDoubleKeyFrame KeyTime="0:0:03" Value="100" />
    <LinearDoubleKeyFrame KeyTime="0:0:04" Value="0" />
    </DoubleAnimationUsingKeyFrames>
    </Storyboard>

    Trigger:

    <phone:PhoneApplicationPage.Triggers>
    <EventTrigger>
    <BeginStoryboard>
    <Storyboard>
    <DoubleAnimation Storyboard.TargetName="TitlePanel"
    Storyboard.TargetProperty="Opacity"
    From="0" To="1" Duration="0:0:10" />
    </Storyboard>
    </BeginStoryboard>
    </EventTrigger>
    </phone:PhoneApplicationPage.Triggers>

    对于Attached属性的动画设置:

    <DoubleAnimationUsingKeyFrames
    Storyboard.TargetName="ball"
    Storyboard.TargetProperty="(Canvas.Left)">
    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="0" />
    <LinearDoubleKeyFrame KeyTime="0:0:1" Value="400" />
    <DiscreteDoubleKeyFrame KeyTime="0:0:2" Value="400" />
    <LinearDoubleKeyFrame KeyTime="0:0:3" Value="0" />
    <DiscreteDoubleKeyFrame KeyTime="0:0:4" Value="0" />
    </DoubleAnimationUsingKeyFrames>

    SplineKeyFrameExperiment:略

    <SplineDoubleKeyFrame KeyTime="0:0:1" Value="10"
    KeySpline="0.75 1, 0.4 0.8" />

    PlaneProjection:

    <TextBlock.Projection>
    <PlaneProjection x:Name="planeProjection">
    </TextBlock.Projection>
    
    <Storyboard x:Name="rotateY">
    <DoubleAnimation Storyboard.TargetName="planeProjection"
    Storyboard.TargetProperty="RotationY"
    From="0" To="360" Duration="0:0:5" />
    </Storyboard>
    
    void RotateXClick(object sender, RoutedEventArgs args)
    {
    rotateX.Begin();
    }

    image

    <phone:PhoneApplicationPage.Projection>
    <PlaneProjection x:Name="planeProjection"
    CenterOfRotationX="0" />
    </phone:PhoneApplicationPage.Projection>
    <phone:PhoneApplicationPage.Triggers>
    <EventTrigger>
    <BeginStoryboard>
    <Storyboard>
    <DoubleAnimation Storyboard.TargetName="planeProjection"
    Storyboard.TargetProperty="RotationY"
    From="-90" To="0" Duration="0:0:01" />
    </Storyboard>
    </BeginStoryboard>
    </EventTrigger>
    </phone:PhoneApplicationPage.Triggers>

    image

  • 相关阅读:
    转载--如果不想一辈子做工程师!
    转-----FPGA工程师:持守梦想or屈于现实
    TIMEQUEST学习之黑金动力(四)
    fir 窗口设计法
    CORDIC逼近算法
    sram的读和写
    ad采样后幅度的衰减
    verilog 之数字电路 边沿检测电路
    verilog 之数字电路 寄存器,触发器。
    da分布式算法
  • 原文地址:https://www.cnblogs.com/otomii/p/2040847.html
Copyright © 2011-2022 走看看