zoukankan      html  css  js  c++  java
  • WPF 动画效果

    线性插值动画、关键帧动画、路径动画

    1. (Visibility)闪烁三下,停下两秒,循环:

    XAML:

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Label Name="WarningShineLabel" Content="充电" Background="DarkRed"></Label>
        </Grid>

    CS

         private void SetVisibilityShine()
            {
                ObjectAnimationUsingKeyFrames okf = new ObjectAnimationUsingKeyFrames();
                okf.Duration = new TimeSpan(0, 0, 0, 0, 4500);
                okf.RepeatBehavior = RepeatBehavior.Forever;
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Hidden, new TimeSpan(0, 0, 0)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Visible, new TimeSpan(0, 0, 0, 0, 500)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Hidden, new TimeSpan(0, 0, 0, 0, 1000)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Visible, new TimeSpan(0, 0, 0, 0, 1500)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Hidden, new TimeSpan(0, 0, 0, 0, 2000)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Visible, new TimeSpan(0, 0, 0, 0, 2500)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Hidden, new TimeSpan(0, 0, 0, 0, 4500)));
    
                WarningShineLabel.BeginAnimation(Label.VisibilityProperty, okf);
            }

    2. 平移:

    XAML

           <Label  Name="AirOutAnimation">
                    <Label.Content>
                        <Image Source="../Icons/flow.png"></Image> <!--一张图片-->
                    </Label.Content>
                </Label>

    CS

            ThicknessAnimation ta = new ThicknessAnimation();
                ta.From = new Thickness(60, 0, 0, 0);
                ta.To = new Thickness(0, 0, 0, 0);
                ta.Duration = TimeSpan.FromSeconds(1.5);
                ta.RepeatBehavior = RepeatBehavior.Forever;
                AirOutAnimation.BeginAnimation(Label.MarginProperty, ta);
  • 相关阅读:
    WPF中更改键盘默认指令小结
    WPF自己喜欢用的数据验证方式
    重写Windows基类,自定义WPF窗口,实现改回车键为TAB
    用CSS控制表格的框格线
    获取当前鼠标的坐标
    SQL 中的转义字符
    資料站點
    jquery 弹出浮层(div) + 遮蔽层
    Jquery放大镜插件[JMagazine]使用参数简介
    邏輯題 交通事故篇
  • 原文地址:https://www.cnblogs.com/pangkang/p/6251594.html
Copyright © 2011-2022 走看看