• 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

  • 相关阅读:
    TP6框架中如何无刷新上传文件
    TP6框架设置验证码的宽度和高度后,验证码显示不全
    TP6模板缓存问题
    TP6管理后台实战第五天文章管理
    20211027技术人为什么建议写博客
    TP6管理后台实战第六天系统管理
    博客园自定义菜单
    xcat无法连接服务器
    lsf安装后配置
    xcat网络无盘启动——添加自定义安装包
  • 原文地址:https://www.cnblogs.com/otomii/p/2040847.html
Copyright © 2020-2023  润新知