WPF ProgressBar显示进度(一)
2014-06-25 11:11
381 查看
ProgressBar显示进度的做法一般采用线程来实现,譬如
xaml代码:
cs代码:
xaml代码:
<Window x:Class="MVVM3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <StackPanel> <TextBlock x:Name="tb" Height="23"></TextBlock> <ProgressBar x:Name="pb" Minimum="0" Maximum="100" Height="20" ></ProgressBar> <Button Content="click" Width="72" Height="23" Click="Button_Click_1"></Button> </StackPanel> </Window>
cs代码:
namespace MVVM3 { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Button_Click_1(object sender, RoutedEventArgs e) { Thread thread = new Thread(new ThreadStart(() => { for (int i = 1; i <= 100; i++) { this.pb.Dispatcher.Invoke(() => this.pb.Value = i); this.tb.Dispatcher.Invoke(() => this.tb.Text = i + "%"); Thread.Sleep(200); } })); thread.Start(); } } }点击click按钮就能看到进度条的进度显示
相关文章推荐
- WPF ProgressBar显示进度(二)
- WPF ProgressBar显示进度(三)
- WPF ProgressBar显示进度(五)
- ProgressBar 实现自定义显示进度值
- 在ProgressBar显示文本进度
- 页面上现有ProgressBar控件progressBar,请用书写线程以10秒的的时间完成其进度显示工作
- Android 自定义带进度显示的半圆形进度条ArcTextProgressBar
- 玩转ProgressBar,设置渐变效果,同时设置两个进度的颜色显示!!!
- ProgressBar进度条10秒显示完成进度工作。
- 软件设计开发 .NET UML OO DataBase c#,winform,progressbar+labe, 联动显示进度
- WPF的ProgressBar进度条
- [转载]两个Form,一个Form中处理数据,另一个是ShowDialog()出来的上面就一个progressBar用来显示进度!!
- 圆弧矩形进度条,可用于在layout或者imageview外层实现进度的显示(改良android-square-progressbar)
- 显示和设置ProgressBar的进度
- 使用ASP.NET Atlas编写显示真实进度的ProgressBar(进度条)控件
- android之GridView异步加载图片时显示加载进度ProgressBar
- WPF调用线程(二)复制文件并显示进度条
- wpf文件复制显示进度条效果(双线程)
- 使用ASP.NET Atlas编写显示真实进度的ProgressBar(进度条)控件
- DataGridView中显示进度条(ProgressBar)