简体   繁体   中英

How to shrink image to disappear gradually in WPF DoubleAnimation

So, I'm making an application and I want to gradually (over the course of a few seconds) shrink an image control until it disappears. So, I basically bound a ScaleTransform with a DoubleAnimation, but it happens instantly. Here is my code:

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

this should do the trick:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM