WPF 动画显示控件
2021-07-09 13:05
标签:wan https vat tar nim 显示 def control void 当我们要显示一个控件的时候,不仅仅要显示这个控件,还要有动画的效果。 主要用到了DoubleAnimation类。 调用的时候也简单。 效果如下: WPF 动画显示控件 标签:wan https vat tar nim 显示 def control void 原文地址:https://www.cnblogs.com/lonelyxmas/p/9706980.html public static void ShowAnimation(object control)
{
Type type = control.GetType();
switch (type.Name)
{
case "Border":
{
Border newBorder = (Border)control;
#region 高、宽变化动画
DoubleAnimation widthAnimation = new DoubleAnimation(0, newBorder.Width, new Duration(TimeSpan.FromSeconds(0.5)));
newBorder.BeginAnimation(Border.WidthProperty, widthAnimation, HandoffBehavior.Compose);
DoubleAnimation heightAnimation = new DoubleAnimation(0, newBorder.Height, new Duration(TimeSpan.FromSeconds(0.5)));
newBorder.BeginAnimation(Border.HeightProperty, heightAnimation, HandoffBehavior.Compose);
#endregion
}
break;
default:
break;
}
}
private void button_Click(object sender, RoutedEventArgs e)
{
bord1.Visibility = Visibility.Visible;
ShowAnimation(bord1);
}
上一篇:.NET 响应式自动缩略图服务器
下一篇:WPF 画心2.0版之元旦快乐