zoukankan      html  css  js  c++  java
  • WIndow初始动画

    XAML版本的:
     
    <Window x:Class="StartAnimation.MainWindow"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             AllowsTransparency="True" WindowStyle="None"
             Title="MainWindow" Height="350" Width="525" RenderTransformOrigin=".5,.5">
       <Window.RenderTransform>
         <ScaleTransform x:Name="scale" />
       </Window.RenderTransform>
       <Window.Triggers>
         <EventTrigger  RoutedEvent="Window.Loaded">
           <BeginStoryboard>
             <Storyboard>
               <DoubleAnimation Storyboard.TargetProperty="ScaleX"
                               Storyboard.TargetName="scale" From="0" To="1"
                                Duration="00:00:01"
                                FillBehavior="HoldEnd"
                                AccelerationRatio=".5" />
               <DoubleAnimation Storyboard.TargetProperty="ScaleY"
                               Storyboard.TargetName="scale" From="0" To="1"
                                Duration="00:00:01"
                                FillBehavior="HoldEnd"
                                AccelerationRatio=".5" />
             </Storyboard>
           </BeginStoryboard>
         </EventTrigger>
       </Window.Triggers>
       <Border CornerRadius="6"    >
         <Border.Background>
           <RadialGradientBrush Center=".5,.5" ColorInterpolationMode="ScRgbLinearInterpolation" >
             <GradientStop Color="Green" Offset=".2"/>
             <GradientStop Color="LightGreen" Offset="1"/>
           </RadialGradientBrush>
         </Border.Background>
       </Border>
     </Window>
     
    CS代码版本的:
     
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
             {
                 ScaleTransform transform = new ScaleTransform() { };
                 this.RenderTransform = transform;
                 this.RenderTransformOrigin = new Point(.5, .5);
                 DoubleAnimation animtion = new DoubleAnimation()
                 {
                     From = 0,
                     To = 1,
                     Duration = TimeSpan.FromSeconds(.5),
                     FillBehavior = FillBehavior.HoldEnd,
                     AccelerationRatio = .5
     
                };
                 transform.BeginAnimation(ScaleTransform.ScaleXProperty, animtion);
                 transform.BeginAnimation(ScaleTransform.ScaleYProperty, animtion);
             }

  • 相关阅读:
    python笔记之re模块学习
    python笔记之面向对象
    C# 静态类和非静态类(实例类)
    占位符的使用
    数据类型和数据类型转换
    win7 安装 memcached
    php 汉字转换成拼音
    apache window环境下本地配置虚拟主机
    在浏览器输入一个网址到得到页面的过程
    浅谈线程池ThreadPoolExecutor核心参数
  • 原文地址:https://www.cnblogs.com/xiaokang088/p/2772659.html
Copyright © 2011-2022 走看看