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);
  • 相关阅读:
    MongoDB的基本操作
    Python 进阶 之 协程
    sublime text3 3143 注册码
    git add 文档
    Corosync 配置描述
    Centos 7 设置 DNS
    2017百度春招<度度熊买帽子的问题>
    leetcode 160. Intersection of Two Linked Lists
    leetcode 155. Min Stack
    leetcode 141 142. Linked List Cycle
  • 原文地址:https://www.cnblogs.com/pangkang/p/6251594.html
Copyright © 2011-2022 走看看