基于vs和C#的WPF应用之动画3

注:1、在内部和外部使用缓动函数

cs 复制代码
<Grid.Resources>
<PowerEase x:Key="powerease" Power="3" EasingMode="EaseInOut"/>
</Grid.Resources>
<DoubleAnimation EasingFunction="{StaticResource powerease}"/>


 <DoubleAnimation.EasingFunction>
 <PowerEase EasingMode="EaseInOut" Power="3"/>
 </DoubleAnimation.EasingFunction>

一、画布

cs 复制代码
<Canvas x:Name="canvas3" Width="200" Height="200" Grid.Row="0" Grid.Column="1">
            <Canvas.Triggers>
                <EventTrigger RoutedEvent="Loaded">
                    <BeginStoryboard Storyboard="{StaticResource third_sb}"/>
                </EventTrigger>
            </Canvas.Triggers>

            <!--背景-->
            <Ellipse Width="100" Height="100" Fill="#f2f4f6" Margin="50"/>
            <Label Content="Loading"
               FontSize="16"
               Margin="50"
               FontFamily="Times New Roman"
               Foreground="#6b48ff"
               FontWeight="Bold"
               Width="100" 
               Height="100"
               VerticalContentAlignment="Center" 
               HorizontalContentAlignment="Center"/>

            <Ellipse Name="third_e1" Style="{StaticResource thirdStyle_Ellipse}" >
                <Ellipse.RenderTransform>
                    <RotateTransform Angle="0"/>
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse Name="third_e2" Style="{StaticResource thirdStyle_Ellipse}">
                <Ellipse.RenderTransform>
                    <RotateTransform Angle="0"/>
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse Name="third_e3" Style="{StaticResource thirdStyle_Ellipse}">
                <Ellipse.RenderTransform>
                    <RotateTransform Angle="0"/>
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse Name="third_e4" Style="{StaticResource thirdStyle_Ellipse}" >
                <Ellipse.RenderTransform>
                    <RotateTransform Angle="0"/>
                </Ellipse.RenderTransform>
            </Ellipse>
            <Ellipse Name="third_e5" Style="{StaticResource thirdStyle_Ellipse}">
                <Ellipse.RenderTransform>
                    <RotateTransform Angle="0"/>
                </Ellipse.RenderTransform>
            </Ellipse>
        </Canvas>

二、动画故事板

cs 复制代码
 <Storyboard x:Key="third_sb" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" RepeatBehavior="Forever">
            <DoubleAnimation Storyboard.TargetName="third_e1" To="360" Duration="0:0:2"  EasingFunction="{StaticResource powerease}" AccelerationRatio="0.1" DecelerationRatio="0.9"/>
            <!--加速比 减速比-->
            <DoubleAnimation Storyboard.TargetName="third_e2" To="360" Duration="0:0:2" EasingFunction="{StaticResource powerease}" AccelerationRatio="0.3" DecelerationRatio="0.7"/>
            <DoubleAnimation Storyboard.TargetName="third_e3" To="360" Duration="0:0:2" EasingFunction="{StaticResource powerease}" AccelerationRatio="0.5" DecelerationRatio="0.5"/>
            <DoubleAnimation Storyboard.TargetName="third_e4" To="360" Duration="0:0:2" EasingFunction="{StaticResource powerease}" AccelerationRatio="0.7" DecelerationRatio="0.3"/>
            <DoubleAnimation Storyboard.TargetName="third_e5" To="360" Duration="0:0:2" EasingFunction="{StaticResource powerease}" AccelerationRatio="0.9" DecelerationRatio="0.1"/>
        </Storyboard>

三、外部样式

cs 复制代码
 <!--第三个动画圆的样式-->
 <Style x:Key="thirdStyle_Ellipse" TargetType="Ellipse">
     <Setter Property="Width" Value="25"/>
     <Setter Property="Height" Value="25"/>
     <Setter Property="Canvas.Left" Value="87.5"/>
     <Setter Property="Canvas.Top" Value="50"/>
     <Setter Property="Fill" Value="#0d3f67"/>
     <Setter Property="RenderTransformOrigin" Value="0.5,2"/>
 </Style>
相关推荐
一枚小小程序员哈1 小时前
基于asp.net 的在线餐饮订餐系统的设计与实现/基于c#的网上订餐系统/餐厅管理系统
后端·c#·asp.net
夏婵语冰1 小时前
实用R语言机器学习指南:从数据预处理到模型实战(附配套学习资源)
开发语言·学习·r语言
好望角雾眠1 小时前
第三阶段数据库-7:sql中函数,运算符,常用关键字
数据库·笔记·sql·学习·sqlserver·c#
牛角上的男孩4 小时前
apt update Ign and 404 Not Found
开发语言·数据库
yzzzzzzzzzzzzzzzzz5 小时前
JavaScript 操作 DOM
开发语言·javascript·ecmascript
海绵宝宝汉堡包6 小时前
c# 项目 文件夹
开发语言·c#
小白要加油努力6 小时前
C++设计模式--策略模式与观察者模式
开发语言·c++·设计模式
小马学嵌入式~7 小时前
数据结构:队列 二叉树
c语言·开发语言·数据结构·算法
Slaughter信仰8 小时前
深入理解Java虚拟机:JVM高级特性与最佳实践(第3版)第二章知识点问答(21题)
java·开发语言·jvm
曹牧8 小时前
C#:窗体间传值
c#