zoukankan      html  css  js  c++  java
  • UserControl 加载动画

    效果:实现加载UserControl动画效果

    cs代码如下

      public  class BaseModuleView : UserControl
        {
            private TranslateTransform CurTranslate;
            private DoubleAnimation XAnim;
            private DoubleAnimation OpacityAnim;
            private double OriginX = 50;
    
            public BaseModuleView()
            {
                DoInitAnin();
                this.Loaded += BaseModuleView_loaded;
                this.Unloaded += BaseModuleView_Unloaded;
            }
    
            private void BaseModuleView_Unloaded(object sender, System.Windows.RoutedEventArgs e)
            {
                DoUnloadAnim();
            }
            private void BaseModuleView_loaded(object sender, System.Windows.RoutedEventArgs e)
            {
                DoLoadAnim();
            }
            private void DoLoadAnim()
            {
                this.CurTranslate.BeginAnimation(TranslateTransform.XProperty, XAnim);
                this.BeginAnimation(UIElement.OpacityProperty, OpacityAnim);
            }
    
            private void DoUnloadAnim()
            {
                this.CurTranslate.BeginAnimation(TranslateTransform.XProperty, null);
                this.BeginAnimation(UIElement.OpacityProperty, null);
    
                this.CurTranslate.X = this.OriginX;
                this.Opacity = 0;
            }
            private void DoInitAnin()
            {
                CurTranslate = new TranslateTransform();
                CurTranslate.X = OriginX;
                RenderTransform = CurTranslate;
                Opacity = 0;
                XAnim = new DoubleAnimation(0, TimeSpan.FromSeconds(0.3));
                XAnim.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut };
                OpacityAnim = new DoubleAnimation(1, TimeSpan.FromSeconds(0.2));
    
            }
        }

    XAML代码:

    <Modules:BaseModuleView
        x:Class="WFA.OwnUserControlown.EarthDayandnightControl"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 xmlns:local="clr-namespace:WFA.OwnUserControlown"
                 xmlns:Modules="clr-namespace:WFA.Modules"
                 mc:Ignorable="d" 
                  xmlns:local1="clr-namespace:WFA" d:DesignHeight="540" d:DesignWidth="960" >
        <Grid>
          
        </Grid>
    </Modules:BaseModuleView>
  • 相关阅读:
    自学Linux Shell14.3-创建临时文件
    自学Linux Shell14.2-在脚本中使用其他文件描述符
    自学Linux Shell14.1-理解输入输出
    自学Linux Shell13.3-获得用户输入(read命令)
    自学Linux Shell13.2-选项处理(主要getopt、getopts命令)
    自学Linux Shell13.1-命令行参数
    自学Linux Shell12.8-循环实例
    自学Linux Shell12.7-控制循环break、continue命令
    自学Linux Shell12.6-嵌套循环for命令
    自学Linux Shell12.5-while、until命令
  • 原文地址:https://www.cnblogs.com/zt199510/p/14209814.html
Copyright © 2011-2022 走看看