zoukankan      html  css  js  c++  java
  • 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)
            {
    
            }
  • 相关阅读:
    一个强迫症用户的锤子手机使用体验
    起点——2015年终总结
    用“MEAN”技术栈开发web应用(三)用mongodb搭建数据库
    用“MEAN”技术栈开发web应用(二)express搭建服务端框架
    SpringBoot/Spring使用@Value进行属性绑定(尚硅谷)
    springboot/spring使用ConfigurationProperties注解读取自定义属性(尚硅谷)
    Spring Boot项目中@SpringBootTest测试的时候卡住,一直Resolving Maven dependencies...
    ASP.NET项目:请使用语言版本6或者更高版本
    安装CUDA坑:CUDA driver version is insufficient for CUDA runtime version
    Failed to load the native TensorFlow runtime. ImportError: libcuda.so.1: cannot open shared object file: No such file or directory
  • 原文地址:https://www.cnblogs.com/NEIL-X/p/4099246.html
Copyright © 2011-2022 走看看