如何在WPF DoubleAnimation中缩小图像逐渐消失

How to shrink image to disappear gradually in WPF DoubleAnimation

所以,我正在制作一个应用程序,我想逐渐(在几秒钟内)缩小图像控件,直到它消失。所以,我基本上将 ScaleTransform 与 DoubleAnimation 绑定在一起,但它会立即发生。这是我的代码:

DoubleAnimation anim = new DoubleAnimation(360, 0, (Duration)TimeSpan.FromSeconds(1));
ScaleTransform st = new ScaleTransform();

st.ScaleX = 0;
st.ScaleY = 0;
PACSCore.RenderTransform = st;
anim.Completed += (s, _) => Exit_PACS();
st.BeginAnimation(ScaleTransform.ScaleYProperty, anim);

这应该可以解决问题:

DoubleAnimation anim = new DoubleAnimation(1, 0,(Duration)TimeSpan.FromSeconds(1));

ScaleTransform st = new ScaleTransform();
Control.RenderTransform = st;
st.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
st.BeginAnimation(ScaleTransform.ScaleYProperty, anim);