如何在WPF DoubleAnimation中缩小图像以逐渐消失
本文关键字:图像 消失 缩小 WPF DoubleAnimation | 更新日期: 2023-09-27 18:01:11
所以,我正在制作一个应用程序,我想逐渐(在几秒钟内(缩小图像控件,直到它消失。所以,我基本上将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);