我是这个领域的新手。我在屏幕上动态创建控件。在按钮上单击我正在更改标签值。我想添加一些带有颜色的淡出动画,以便捕捉用户的视图,从而表明屏幕上发生了某些事情。目前我正在使用它来隐藏带有淡入淡出动画的控件
myLabel.Visibility = System.Windows.Visibility.Visible;
var a = new DoubleAnimation
{
From = 1.0,
To = 0.0,
FillBehavior = FillBehavior.Stop,
BeginTime = TimeSpan.FromSeconds(2),
Duration = new Duration(TimeSpan.FromSeconds(0.5))
};
var storyboard = new Storyboard();
storyboard.Children.Add(a);
Storyboard.SetTarget(a, myLabel);
Storyboard.SetTargetProperty(a, new PropertyPath(OpacityProperty));
storyboard.Completed += delegate { myLabel.Visibility = System.Windows.Visibility.Hidden; };
storyboard.Begin();
相反,我必须使用一些黄色颜色框作为背景,它会淡出,以便指示屏幕上发生的事情。任何帮助将不胜感激