WPF动画效果学习记录

用Border做一个进入动画

  <Border x:Name="TestBorder"
                Width="120"
                Height="60"
                Background="#353535">
     
            <Grid>
                <Border x:Name="LightBorder"
                        Height="10"
                        Width="30"
                        Margin="-85 -45 0 0"
                        CornerRadius="5">
                    <Border.Background>
                    <!--目前只是研究出了用SolidColorBrush来做颜色动画-->
                        <SolidColorBrush Color="#FF8C00">
                        </SolidColorBrush>
                    </Border.Background>
                </Border>
                <TextBlock Text="UserControl" 
                           Margin="40 0 0 0"
                           Foreground="#FF9C00"/>
                <TextBlock x:Name="TextTest" Width="100" Height="40" Margin="0 10 0 0"/>
            </Grid>
            <Border.Triggers>
                <EventTrigger RoutedEvent="Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="LightBorder"
                                                          Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
                                                          BeginTime="0:0:0"
                                                          Duration="0:0:2"
                                                          FillBehavior="HoldEnd"
                                                          RepeatBehavior="Forever">
                                <ColorAnimationUsingKeyFrames.KeyFrames>
                                    <DiscreteColorKeyFrame KeyTime="0:0:0"
                                                           Value="#FFFFFF"/>
                                    <DiscreteColorKeyFrame KeyTime="0:0:0.1"
                                                           Value="#5B5B5B"/>
                                    <DiscreteColorKeyFrame KeyTime="0:0:0.25"
                                                           Value="#FFFFFF"/>
                                    <DiscreteColorKeyFrame KeyTime="0:0:0.3"
                                                           Value="#5B5B5B"/>
                                </ColorAnimationUsingKeyFrames.KeyFrames>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Border.Triggers>
        </Border>

Border 进入动画

  <Border x:Name="TestBorder"
                Width="120"
                Height="60"
                Background="#353535">
            <Border.RenderTransform>
                <TranslateTransform X="0"
                                    Y="-270"/>
            </Border.RenderTransform>
            <Grid>
                <Border x:Name="LightBorder"
                        Height="10"
                        Width="30"
                        Margin="-85 -45 0 0"
                        CornerRadius="5">
                    <Border.Background>
                        <SolidColorBrush Color="#FF8C00">

                        </SolidColorBrush>
                    </Border.Background>
                </Border>
                <TextBlock Text="UserControl" 
                           Margin="40 0 0 0"
                           Foreground="#FF9C00"/>
                <TextBlock x:Name="TextTest" Width="100" Height="40" Margin="0 10 0 0"/>
            </Grid>
            <Border.Triggers>
                <EventTrigger RoutedEvent="Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="TestBorder"
                                             Storyboard.TargetProperty="RenderTransform.(TranslateTransform.Y)"
                                             From="-270"
                                             To="0"
                                             BeginTime="0:0:0"
                                             Duration="0:0:0.2">
                                             <!--缓存动画,感觉像是逐渐加速效果-->
                                             <DoubleAnimation.EasingFunction>
                                    			<CircleEase EasingMode="EaseIn"/>
                               				 </DoubleAnimation.EasingFunction>
                            </DoubleAnimation >
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Border.Triggers>
        </Border>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值