• WPF 动画显示控件


       当我们要显示一个控件的时候,不仅仅要显示这个控件,还要有动画的效果。

       主要用到了DoubleAnimation类。

     public static void ShowAnimation(object control)
            {
                Type type = control.GetType();
                switch (type.Name)
                {
                    case "Border":
                        {
                            Border newBorder = (Border)control;
                            #region 高、宽变化动画
    
                            DoubleAnimation widthAnimation = new DoubleAnimation(0, newBorder.Width, new Duration(TimeSpan.FromSeconds(0.5)));
                            newBorder.BeginAnimation(Border.WidthProperty, widthAnimation, HandoffBehavior.Compose);
    
                            DoubleAnimation heightAnimation = new DoubleAnimation(0, newBorder.Height, new Duration(TimeSpan.FromSeconds(0.5)));
                            newBorder.BeginAnimation(Border.HeightProperty, heightAnimation, HandoffBehavior.Compose);
                            #endregion
                        }
                        break;
    
                    default:
                        break;
                }
            }

    调用的时候也简单。

    private void button_Click(object sender, RoutedEventArgs e)
            {
                bord1.Visibility = Visibility.Visible;
                ShowAnimation(bord1);
            }

    效果如下:

    高山流水,海纳百川!
  • 相关阅读:
    GCC编绎详解
    GUN C/C++ __attribute__ 用法 转
    rust 参考的资料 转
    Eclipse环境安装rust
    GNU Debugger for Windows----GDB
    minGW cygwin gnuwin32
    tdm-gcc
    GNU tools
    The MinGW and mingw-w64 projects.----GCC
    crosstool-NG
  • 原文地址:https://www.cnblogs.com/ahcc08/p/6217383.html
Copyright © 2020-2023  润新知