我有一个名为MainStack的StackPanel。我正在尝试通过使用ThicknessAnimation设置其margin top属性的动画来垂直向下移动堆栈面板。老实说,我不知道为什么我的代码没有做任何事情。任何帮助,将不胜感激。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
namespace casino
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ThicknessAnimation myThicknessAnimation = new ThicknessAnimation();
myThicknessAnimation.Duration = TimeSpan.FromSeconds(5);
myThicknessAnimation.FillBehavior = FillBehavior.HoldEnd;
myThicknessAnimation.From = new Thickness(20, 20, 0, 0);
myThicknessAnimation.To = new Thickness(20, 200, 0, 0);
Storyboard.SetTargetName(myThicknessAnimation, "MainStack");
Storyboard.SetTargetProperty(
myThicknessAnimation, new
PropertyPath(Border.BorderThicknessProperty));
Storyboard ellipseStoryboard = new Storyboard();
ellipseStoryboard.Children.Add(myThicknessAnimation);
}
}
}