• WP8.1 Study3:WP8.1中Animation应用


    WP8.1上的Animation动画的API和WIN8/WIN8.1上的差不多,网上可以找到很多资料,同时可以去MSDN看官方文档。

    下面是我参考一些资料,写出来的例子,希望以后有用。

    xaml代码如下:

    <Grid>
            <StackPanel>
                <StackPanel.Resources>
                    <!--DoubleAnimation-->
                    <Storyboard x:Name="showAnimation">
                        <DoubleAnimation Storyboard.TargetName="animatedImage"
                                         Storyboard.TargetProperty="Opacity"
                                         From="0"
                                         To="1"
                                         Duration="0:0:2"/>
                    </Storyboard>
                    <Storyboard x:Name="HideAnimation">
                        <DoubleAnimation Storyboard.TargetName="animatedImage"
                                         Storyboard.TargetProperty="Opacity"
                                         From="1" 
                                         To="0"
                                         Duration="0:0:2"/>
                    </Storyboard>
                    <!--FadeTheAnimation-->
                    <Storyboard x:Name="fadeinAnimation">
                        <FadeInThemeAnimation Storyboard.TargetName="animatedrectangle"
                                              FillBehavior="HoldEnd"
                                              SpeedRatio="8"
                                              Duration="0:0:4"/>
                    </Storyboard>
                    <Storyboard x:Name="fadeoutAnimation">
                        <FadeOutThemeAnimation Storyboard.TargetName="animatedrectangle"
                                               SpeedRatio="0.1"
                                               Duration="0:0:4"/>
                    </Storyboard>
                    <!--ColorAnimation-->
                    <Storyboard x:Name="coloranimation">
                        <ColorAnimation Storyboard.TargetName="animatedEllipse"
                                        Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)"
                                        From="Red"
                                        To="Blue"
                                        Duration="0:0:2"/>
                    </Storyboard>
                    <!--
                        PointerDownThemeAnimation - 鼠标(手指)在控件上按下时的动画
                    -->
                    <Storyboard x:Name="storyboardPointerDown">
                        <PointerDownThemeAnimation Storyboard.TargetName="border" />
                    </Storyboard>
    
                    <!--
                        PointerUpThemeAnimation - 鼠标(手指)在控件上抬起时的动画
                    -->
                    <Storyboard x:Name="storyboardPointerUp">
                        <PointerUpThemeAnimation Storyboard.TargetName="border" />
                    </Storyboard>
            
                </StackPanel.Resources>
                
                <!--控件-->
                <Button Name="show" Content="show" Width="80" Height="50" Click="show_Click"/>
                <Button Name="hide" Content="hide" Width="80" Height="50" Click="hide_Click"/>
                <Image Name="animatedImage"
                       Source="blue.png"
                       Opacity="0"
                       Width="100"
                       Height="100"
                       ImageOpened="animatedImage_ImageOpened"/>
                <Rectangle Name="animatedrectangle"  Fill="RosyBrown" Width="100" Height="100"/>
                    <Ellipse Name="animatedEllipse"  Fill="Red" Width="100" Height="100"/>
                <Border Name="border" BorderThickness="5" BorderBrush="Red" Background="Blue" CornerRadius="10" Width="400" Height="100" HorizontalAlignment="Left">
                    <Border.Child>
                        <TextBlock Text="我是 Border 里的内容" FontSize="24.667" TextAlignment="Center" VerticalAlignment="Center" />
                    </Border.Child>
                </Border>
            </StackPanel>
    
        </Grid>

    当前页面的主要C#代码如下:

     private void show_Click(object sender, RoutedEventArgs e)
            {
                showAnimation.Begin();
                fadeinAnimation.Begin();
                coloranimation.Begin();
                storyboardPointerUp.Begin();
            }
    
            private void hide_Click(object sender, RoutedEventArgs e)
            {
                HideAnimation.Begin();
    
                fadeoutAnimation.Begin();
                storyboardPointerDown.Begin();
            }
    
            private void animatedImage_ImageOpened(object sender, RoutedEventArgs e)
            {
    
            }
  • 相关阅读:
    SQLServer数据库中开启CDC导致“事务日志空间被占满,原因为REPLICATION”的原因分析和解决办法
    译:SQL Server的Missing index DMV的 bug可能会使你失去理智---慎重看待缺失索引DMV中的信息
    SQLServer中间接实现函数索引或者Hash索引
    MySQL缓存分类和配置
    MySQL系统变量配置基础
    MySQL索引统计信息更新相关的参数
    Sql Server优化---统计信息维护策略
    SQL Server 用角色(Role)管理数据库权限
    sp_executesql 或者 EXECUTE 执行动态sql的权限问题
    关于T-SQL重编译那点事,内联函数和表值函数在编译生成执行计划的区别
  • 原文地址:https://www.cnblogs.com/NEIL-X/p/4099246.html
Copyright © 2020-2023  润新知