wpf ProgressBar使用
wpf progressBar使用起来有些麻烦,直接设置value的值还不行
而是通过委托来执行setValue方法
//Create a Delegate that matches the Signature of the ProgressBar's SetValue method
private delegate void UpdateProgressBarDelegate(System.Windows.DependencyProperty dp, Object value);
private void Process()
{
//Configure the ProgressBar
ProgressBar1.Minimum = 0;
ProgressBar1.Maximum = 600;
ProgressBar1.Value = 0;
//Stores the value of the ProgressBar
double value = 0;
//Create a new instance of our ProgressBar Delegate that points
// to the ProgressBar's SetValue method.
UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(ProgressBar1.SetValue);
//Tight Loop: Loop until the ProgressBar.Value reaches the max
do
{
value += 1;
/*Update the Value of the ProgressBar:
1) Pass the "updatePbDelegate" delegate that points to the ProgressBar1.SetValue method
2) Set the DispatcherPriority to "Background"
3) Pass an Object() Array containing the property to update (ProgressBar.ValueProperty) and the new value */
Dispatcher.Invoke(updatePbDelegate,
System.Windows.Threading.DispatcherPriority.Background,
new object[] { ProgressBarEdit.ValueProperty, value });
}
while (ProgressBar1.Value != ProgressBar1.Maximum);
}
以上红色代码是关键处。
wpf ProgressBar使用的更多相关文章
- WPF ProgressBar 样式
<ProgressBar Grid.Row="2" Foreground="#45d207" IsIndeterminate="True&quo ...
- (转)WPF控件开源资源
(转)WPF控件开源资源 Textbox Drag/Drop in WPFhttp://www.codeproject.com/Articles/42696/Textbox-Drag-Drop-in- ...
- Some beautiful Progress Bars in WPF
1.Better WPF Circular Progress Bar 2.Bending the WPF ProgressBar 3.A CIRCULAR PROGRESSBAR STYLE USIN ...
- WPF控件开源资源
(转)WPF控件开源资源 Textbox Drag/Drop in WPFhttp://www.codeproject.com/Articles/42696/Textbox-Drag-Drop-in- ...
- wpf相关好资源
Textbox Drag/Drop in WPFhttp://www.codeproject.com/Articles/42696/Textbox-Drag-Drop-in-WPF.aspx Odys ...
- WPF的进度条progressbar,运行时间elapse time和等待spinner的实现
今天用.NET 4.5中的TPL的特性做了个小例子,实现了WPF的进度条progressbar,运行时间elapse time和等待spinner. 先上图吧. 这个例子包含4个实现,分别是同步版 ...
- WPF备忘录(2)WPF获取和设置鼠标位置与progressbar的使用方法
一.WPF 中获取和设置鼠标位置 方法一:WPF方法 Point p = Mouse.GetPosition(e.Source as FrameworkElement); Point p = (e.S ...
- WPF 进度条ProgressBar
今天研究了一下wpf的进度条ProgressBar 1.传统ProgressBar WPF进度条ProgressBar 这个控件,如果直接写到循环里,会死掉,界面会卡死,不会有进度.需要把进度条放到单 ...
- WPF获取和设置鼠标位置与progressbar的使用方法
一.WPF 中获取和设置鼠标位置 方法一:WPF方法 Point p = Mouse.GetPosition(e.Source as FrameworkElement); Point p = (e.S ...
随机推荐
- 代码审查 (Google牛人谈Code Review)
代码审查 (Google牛人谈Code Review) 在上一篇博客里我暗示自己将不在为Google工作. 我还没有决定好去哪儿-有几个非常不错的工作机会让我选择.鉴于这段时间内我不受雇于任何公司,我 ...
- Javascript Array API
JS数组对象提供了很多API方法,由于前段时间要用到某一些方法,但是突然一时又想不起来该怎么用了,上网找有很多资料都不全,所以就自己整理了一篇,完全是自己写的的JS,只是复制到这里来了 ,要用到的朋友 ...
- AngularJS的依赖注入方式
在定义controller,module,service,and directive时有两种方式, 方式一: var myModule = angular.module('myApp', []); m ...
- wcf消息模式(随记)
----------------------------------------------消息模式:1.request\reply(默认)2.one-way(单工)[Isoneway=true]客户 ...
- Mvc快速开发
Asp.Net Mvc + ComBoost.Mvc快速开发 ComBoost项目地址 http://comboost.wodsoft.com https://github.com/Kation/ ...
- ASP.NET MVC+Knockout+Web API+SignalR
架构设计(ASP.NET MVC+Knockout+Web API+SignalR) 架构设计(ASP.NET MVC+Knockout+Web API+SignalR) 2014-01-16 18: ...
- jsoneditor显示Json data
Git开源地址:https://github.com/josdejong/jsoneditor/blob/master/docs/api.md 1.引用JS文件 <!-- jsoneditor ...
- C++库研究笔记——函数名的宏定义
6.47 Function Names as Strings:http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html GCC provides th ...
- 应用facebook .net sdk
1.本博客主要介绍如何应用facebook .net SDK,实现发帖.点赞.上传照片视频等功能,更多关于facebook API,请参考:https://developers.facebook.co ...
- 如何本地测试例如QQ登录等第三方接口
前言:现在基本是个网站就会集成第三方的一些接口,比如QQ登录.分享等等.但是在开发的时候,尤其是没有这方面经验的开发人员来说,调试流程时会显得迷茫,不知道怎么调试.这里就个人的这方面学习摸索做一个总结 ...