这个动画绕x轴旋转加上位置偏移
参考代码:
public MainPage() { InitializeComponent(); button2.Visibility = Visibility.Collapsed; } int n = -512; private void button1_Click(object sender, RoutedEventArgs e) { button2.Projection = new PlaneProjection { RotationX=n<0?270:0 }; button2.Visibility = Visibility.Visible; if (n < 0) button2.Margin = new Thickness(512, button2.Margin.Top, 0, 0); else button2.Margin = new Thickness(0, button2.Margin.Top, 0, 0); var st = new Storyboard(); st.Completed += (a, b) => { if (n < 0) button2.Visibility = Visibility.Collapsed; }; var a1 = new DoubleAnimation { To=n<0?0:-270, Duration=TimeSpan.FromSeconds(0.75), AutoReverse=false }; Storyboard.SetTarget(a1, button2.Projection); Storyboard.SetTargetProperty(a1,new PropertyPath("RotationX")); st.Children.Add(a1); var a2 = new DoubleAnimation { To = n, Duration = TimeSpan.FromSeconds(0.75), AutoReverse = false }; Storyboard.SetTarget(a2, button2.Projection); Storyboard.SetTargetProperty(a2,new PropertyPath("LocalOffsetX")); st.Children.Add(a2); st.Begin(); n *= -1; }