Windows 8 metro app - animating a stack panel?

谁说我不能喝 提交于 2019-12-08 12:28:43

问题


I'm making a button that will disappear my stack panel:

public void myButton (object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
     myStackPanel.Visibility = Visibility.Collapsed;
}

However, I would also like to perform a little animation when getting rid of that stack panel.

Just a simple animation like fading from left to right. What codes should I add on my myButton?


回答1:


You can use a FadeOutThemeAnimation, as described here: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.media.animation.fadeoutthemeanimation.aspx.




回答2:


If you want to do something right there in your codebehind, you could try something like this.

DoubleAnimation fadeout = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(2), FillBehavior.HoldEnd);
fadeout.BeginTime = TimeSpan.FromSeconds(0);
Storyboard sb = new Storyboard();
Storyboard.SetTarget(fadeout, myStackPanel);
Storyboard.SetTargetProperty(fadeout, new PropertyPath("(Opacity)"));
sb.Children.Add(fadeout);
sb.Begin();


来源:https://stackoverflow.com/questions/12835017/windows-8-metro-app-animating-a-stack-panel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!