zoukankan      html  css  js  c++  java
  • wpf 动画结束后保留end值,动画结束后会失去绑定,可以在completed事件重新进行绑定

    https://blog.csdn.net/openzpc/article/details/50588063

    动画结束后会失去绑定,可以在completed事件重新进行绑定

    rightToLeftInverseAnimation = new ThicknessAnimation();
    rightToLeftInverseAnimation.From = new Thickness(btnIcon.Margin.Left - menuPanelOriWidth + btnIcon.Width, btnIcon.Margin.Top, btnIcon.Margin.Right, btnIcon.Margin.Bottom);
    rightToLeftInverseAnimation.To = new Thickness(btnIcon.Margin.Left, btnIcon.Margin.Top + btnIcon.Width, btnIcon.Margin.Right, btnIcon.Margin.Bottom);
    rightToLeftInverseAnimation.Duration = TimeSpan.FromMilliseconds(animationTimesMs);
    rightToLeftInverseAnimation.FillBehavior = FillBehavior.Stop;
    rightToLeftInverseAnimation.Completed += new EventHandler((sender, e) =>
    {
    menu.Margin = btnIcon.Margin;
    Binding binding = new Binding();
    binding.Path = new System.Windows.PropertyPath(MarginProperty);
    binding.Mode = BindingMode.OneWay;
    binding.ElementName = "btnIcon";
    binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
    menu.SetBinding(MarginProperty, binding);
    });
    Storyboard.SetTargetName(rightToLeftInverseAnimation, nameof(menu));
    Storyboard.SetTargetProperty(rightToLeftInverseAnimation, new PropertyPath(Panel.MarginProperty));

                if (!hideStoryboard.Children.Contains(rightToLeftInverseAnimation))
                {
                    hideStoryboard.Children.Add(rightToLeftInverseAnimation);
                }
  • 相关阅读:
    KMP模板
    洛谷 [P2701] 巨大的牛棚
    浅谈用极大化思想解决最大子矩阵问题
    洛谷 [P1578] WC2002 奶牛浴场
    洛谷 [P1040]加分二叉树
    洛谷 [P1220] 关路灯
    清北学堂复习笔记
    一些比较实用的网站
    图论模板
    一些应该注意的问题
  • 原文地址:https://www.cnblogs.com/swobble/p/15698874.html
Copyright © 2011-2022 走看看