WPF动画进度条

WPF动画进度条
在这里插入图片描述
前台代码

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="AnimationTiming.AutoReverseExample" 
  WindowTitle="AutoReverse Example">
  <StackPanel Margin="20" Background="{StaticResource MyGridBrushResource}">
      
     <!-- <Border Style="{StaticResource myIntroTextBorderStyle}">  -->
     <Border>
        <TextBlock Margin="20">
          This example shows how to use the AutoReverse property to make a timeline play backwards at the end of each iteration. 
          Several rectangles
          are animated by DoubleAnimations with identical durations and target values, but with different
          AutoReverse and RepeatBehavior settings.
        </TextBlock>
      </Border>
      
      
      <TextBlock>AutoReverse="False" (Default)</TextBlock>
      <Rectangle Name="withoutAutoReverseRectangle"
        Width="100" Height="20" Fill="#AA3333FF" HorizontalAlignment="Left" />
      
      <TextBlock Margin="0,20,0,0">AutoReverse="True"</TextBlock>
      <Rectangle Name="autoReverseRectangle"
        Width="100" Height="20" Fill="#AA3333FF" HorizontalAlignment="Left" />
       
        
      <TextBlock Margin="0,20,0,0">AutoReverse="True"<LineBreak /> RepeatBehavior="2x"</TextBlock>
      <Rectangle Name="autoReverseRectangleWithRepeats"
        Width="100" Height="20" Fill="#AA3333FF" HorizontalAlignment="Left" />
        
      <TextBlock Margin="0,20,0,0" >
       In this example, AutoReverse="True" and RepeatBehavior="2x" have been set on the
       animation's parent timeline.
       </TextBlock>
      <Rectangle Name="complexAutoReverseExample"
        Width="100" Height="20" Fill="#AA3333FF" HorizontalAlignment="Left" />
    
    
    
    <!-- Create a button to restart the animations. -->
    <Button Margin="0,30,0,0" HorizontalAlignment="Left">Restart Animations
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Click">
          <BeginStoryboard>
            <Storyboard>

              <!-- Create an animation that does not automatically play in reverse. -->
              <DoubleAnimation 
                Storyboard.TargetName="withoutAutoReverseRectangle" 
                Storyboard.TargetProperty="(Rectangle.Width)" 
                Duration="0:0:2" From="100" To="400" AutoReverse="False" />   

              <!-- Create an animation that automatically reverses at the end of each iteration. -->
              <DoubleAnimation Storyboard.TargetName="autoReverseRectangle" 
                Storyboard.TargetProperty="(Rectangle.Width)"
                Duration="0:0:2" From="100" To="400" AutoReverse="True" />
        
              <!-- Create an animation that automatically reverses at the end of each iteration.
                   Set the animation to repeat twice. As a result, then animation plays forward,
                   the backward, then forward, and then backward again. -->
              <DoubleAnimation Storyboard.TargetName="autoReverseRectangleWithRepeats" 
                Storyboard.TargetProperty="(Rectangle.Width)"
                Duration="0:0:2" From="100" To="400" AutoReverse="True" RepeatBehavior="2x" />  
                
              <!-- Set the parent timeline's AutoReverse property to True and set the animation's
                   RepeatBehavior to 2x. As a result, the animation plays forward twice and then
                   backwards twice. -->                
              <ParallelTimeline AutoReverse="True">
                <DoubleAnimation Storyboard.TargetName="complexAutoReverseExample" Storyboard.TargetProperty="(Rectangle.Width)"
                  Duration="0:0:2" From="100" To="400" RepeatBehavior="2x"  />  
              </ParallelTimeline>
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Button.Triggers>
    </Button>
  </StackPanel>
</Page>

后台代码

using System.Windows.Controls;

namespace AnimationTiming
{
    public partial class AutoReverseExample : Page
    {
    }
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

向着光-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值