public void Execute(object parameter) { //if (parameter is FrameworkElement element) //{ // ThicknessAnimation marginAnimation = new ThicknessAnimation(); // marginAnimation.From = new Thickness(0, 0, 0, 0); // marginAnimation.To = new Thickness(-element.ActualWidth, 0, 0, 0); // marginAnimation.Duration = TimeSpan.FromSeconds(0.5); // marginAnimation.Completed+= (l, k) => // { // element.Visibility = Visibility.Hidden; // }; // element.BeginAnimation(FrameworkElement.MarginProperty, marginAnimation); //} if (parameter is FrameworkElement element) { var engine = DoubleStoryboardEngine.Create(400, 0, 0.5, FrameworkElement.WidthProperty.Name); engine.CompletedEvent += (l, k) => { element.Visibility = Visibility.Collapsed; }; engine.Start(element); } }
public void Execute(object parameter) { if (parameter is UIElement element) { var engine = DoubleStoryboardEngine.Create(1, 0, 1, "Opacity"); engine.Start(element); } }
public void Execute(object parameter) { if (parameter is UIElement element) { element.Visibility = Visibility.Visible; var engine = DoubleStoryboardEngine.Create(0, 1, 0.4, UIElement.OpacityProperty.Name); engine.Start(element); } }
public void Execute(object parameter) { if (parameter is UIElement element) { var engine = DoubleStoryboardEngine.Create(1, 0, 1, "Opacity"); engine.CompletedEvent += (l, k) => { element.Visibility = Visibility.Collapsed; }; engine.Start(element); } }
public void Execute(object parameter) { //if (parameter is FrameworkElement element) //{ // element.Visibility = Visibility.Visible; // ThicknessAnimation marginAnimation = new ThicknessAnimation(); // marginAnimation.From = new Thickness(-element.ActualWidth, 0, 0, 0); // marginAnimation.To = new Thickness(0, 0, 0, 0); // marginAnimation.Duration = TimeSpan.FromSeconds(0.5); // element.BeginAnimation(FrameworkElement.MarginProperty, marginAnimation); //} if (parameter is UIElement element) { element.Visibility = Visibility.Visible; var engine = DoubleStoryboardEngine.Create(0, 400, 0.5, FrameworkElement.WidthProperty.Name); engine.Start(element); } }
/// <summary> 执行动画 </summary> public static void BegionDoubleStoryBoard(this UIElement element, double start, double end, double duration, string propertyName) { var engine = DoubleStoryboardEngine.Create(start, end, duration, propertyName); engine.Start(element); }