基本信息
源码名称:WPF Animation
源码大小:0.22M
文件格式:.rar
开发语言:C#
更新时间:2024-03-27
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

1. WPF 使用后台代码创建动画

2. 使用前端XAML创建动画

3. easing 动画

4. 关键帧动画

5. 动画缓存


关键帧动画

<Window x:Class="Animation.FrameRates"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="FrameRates" Height="410.4" Width="405.6"
    >
  <Window.Resources>
    <BeginStoryboard x:Key="beginStoryboard">
      <Storyboard Timeline.DesiredFrameRate="{Binding ElementName=txtFrameRate,Path=Text}">
        <DoubleAnimation Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Canvas.Left)"
                         From="0" To="300" Duration="0:0:5">
        </DoubleAnimation>
        <DoubleAnimation Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Canvas.Top)"
                         From="300" To="0" AutoReverse="True" Duration="0:0:2.5"
                         DecelerationRatio="1">
        </DoubleAnimation>
      </Storyboard>
    </BeginStoryboard>
  </Window.Resources>
  
  <Window.Triggers>
    <EventTrigger RoutedEvent="Window.Loaded">
      <EventTrigger.Actions>
        <StaticResource ResourceKey="beginStoryboard"></StaticResource>
      </EventTrigger.Actions>
    </EventTrigger>
  </Window.Triggers>

  <Grid Background="LightGoldenrodYellow" >
    <Grid.RowDefinitions>
      <RowDefinition></RowDefinition>
      <RowDefinition Height="Auto"></RowDefinition>
      <RowDefinition Height="Auto"></RowDefinition>
    </Grid.RowDefinitions>

    <Border Background="White" BorderBrush="DarkGray" BorderThickness="3" Width="300" Height="300" HorizontalAlignment="Center" VerticalAlignment="Center">
      <Canvas ClipToBounds="True">
        <Ellipse Name="ellipse" Fill="Red" Width="10" Height="10"></Ellipse>
      </Canvas>
    </Border>

    <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
      <TextBlock VerticalAlignment="Center" xml:space="preserve">Desired Frame Rate:  </TextBlock>
      <TextBox Grid.Column="2" Width="50" Name="txtFrameRate">60</TextBox>
    </StackPanel>
    <Button Grid.Row="2" HorizontalAlignment="Center" Padding="3" Margin="3">
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Click">
          <StaticResource ResourceKey="beginStoryboard"></StaticResource>
        </EventTrigger>
      </Button.Triggers>
      <Button.Content>
        Repeat
      </Button.Content>
    </Button>
  </Grid>
   
</Window>