社区
WPF/Silverlight
帖子详情
WPF,后台处理耗时任务,前台显示等待动画Demo
eHuaTian
2015-02-28 12:32:10
WPF,后台处理耗时任务,前台显示等待动画Demo(动画效果可以仿Win8等待效果)。急求可测试可以运行的代码。
...全文
1821
4
打赏
收藏
WPF,后台处理耗时任务,前台显示等待动画Demo
WPF,后台处理耗时任务,前台显示等待动画Demo(动画效果可以仿Win8等待效果)。急求可测试可以运行的代码。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
稀饭_RD
2015-03-12
打赏
举报
回复
private void Init3() { Button btn=new Button(); btn.Name="ThreadButton"; btn.Content="异步动画"; btn.Click+=new RoutedEventHandler(btn_click); Canvas.SetTop(btn, 100); Canvas.SetZIndex(btn, 0); board.Children.Add(btn); } void btn_click(object sender, EventArgs e) { // 你的动画控件 Canvas cv = new Canvas(); cv.Width = this.ActualWidth; cv.Height = this.ActualHeight; cv.Visibility = System.Windows.Visibility.Hidden; cv.Background = Brushes.Silver; Rectangle rt = new Rectangle(); rt.Width = rt.Height = 50; rt.Fill = Brushes.Red; cv.Children.Add(rt); Canvas.SetTop(rt, 0); Canvas.SetLeft(rt, 0); cv.MouseLeftButtonDown += new MouseButtonEventHandler(cv_MouseLeftButtonDown); Canvas.SetZIndex(cv, 10); board.Children.Add(cv); System.Threading.Thread td = new System.Threading.Thread ( new System.Threading.ParameterizedThreadStart(s =>{ // TODO Background Work System.Threading.Thread.Sleep(2000); this.Dispatcher.BeginInvoke( new System.Threading.ThreadStart(delegate() { cv.Visibility = System.Windows.Visibility.Hidden; })); }) ); td.Start(); cv.Visibility = System.Windows.Visibility.Visible; } void cv_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Canvas cv = sender as Canvas; Rectangle rt = cv.Children[0] as Rectangle; Point pt = e.GetPosition(cv); Storyboard storyboard = new Storyboard(); DoubleAnimation doubleAnimationX = new DoubleAnimation(Canvas.GetLeft(rt),pt.X, new Duration(TimeSpan.FromMilliseconds(200))); Storyboard.SetTarget(doubleAnimationX, rt); Storyboard.SetTargetProperty(doubleAnimationX, new PropertyPath("(Canvas.Left)")); storyboard.Children.Add(doubleAnimationX); DoubleAnimation doubleAnimationY = new DoubleAnimation(Canvas.GetTop(rt), pt.Y, new Duration(TimeSpan.FromMilliseconds(200))); Storyboard.SetTarget(doubleAnimationY, rt); Storyboard.SetTargetProperty(doubleAnimationY, new PropertyPath("(Canvas.Top)")); storyboard.Children.Add(doubleAnimationY); storyboard.Begin(); }
exception92
2015-03-04
打赏
举报
回复
http://www.cnblogs.com/linyijia/archive/2013/02/06/2900609.html
eHuaTian
2015-03-03
打赏
举报
回复
能不能来段实在的代码
灬浪子灬
2015-02-28
打赏
举报
回复
异步
WPF
呼吸闪烁效果例子
一个
WPF
呼吸闪烁效果的例子 更多资源: http://cleopard.download.csdn.net
WPF
窗体缩放源码
WPF
窗体缩放源码例子 更多资源: http://cleopard.download.csdn.net
WPF
实现超酷样式按钮
WPF
实现超酷样式按钮
WPF
全系列事例代码
WPF
基础教程所有相关的源代码,博客文章请查阅:http://blog.csdn.net/fwj380891124 之
WPF
板块类容。非常详细的介绍了
WPF
,适合初学者入门学习。
WPF
自定义图片按钮[ImageButton
WPF
]
WPF
自定义图片按钮[ImageButton
WPF
] 更多资源: http://cleopard.download.csdn.net
WPF/Silverlight
8,735
社区成员
12,029
社区内容
发帖
与我相关
我的任务
WPF/Silverlight
WPF/Silverlight相关讨论
复制链接
扫一扫
分享
社区描述
WPF/Silverlight相关讨论
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章