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

时间:2015-07-05 17:35:31

标签: c# 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);

1 个答案:

答案 0 :(得分:2)

这应该可以解决问题:

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);