C#代码生成控件动态效果-XAML篇

来源:互联网 发布:小明看看发布永久域名 编辑:程序博客网 时间:2023/02/03 01:34
1.动态改变控件透明度
private void CreateFadeInAnimation(UIElement btn)        {            Duration dur = new Duration()            {                Type = DurationType.TimeSpan,                TimeSpan = TimeSpan.FromSeconds(1)            };            var da = new DoubleAnimation();            da.AutoReverse = false;            da.From = 0;            da.To = 1;            var sb = new Storyboard();            sb.Duration = dur;            sb.Children.Add(da);            Storyboard.SetTarget(da, btn);            Storyboard.SetTargetProperty(da, "(Opacity)");            sb.Begin();        }

原创粉丝点击