WPF實(shí)現(xiàn)進(jìn)度條實(shí)時更新效果
更新時間:2018年12月26日 17:23:01 作者:有個家伙喜歡代碼
這篇文章主要為大家詳細(xì)介紹了WPF實(shí)現(xiàn)進(jìn)度條實(shí)時更新效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了WPF實(shí)現(xiàn)一個實(shí)時更新的進(jìn)度條,供大家參考,具體內(nèi)容如下
效果圖
xaml代碼
<Window x:Class="ProgressBar.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ProgressBar" mc:Ignorable="d" Title="MainWindow" Height="250" Width="400"> <Grid> <ProgressBar Name="progressBar" Minimum="1" Maximum="1000" Height="50"/> <Button Content="Done" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="20" Margin="10" Click="Button_Click"/> </Grid> </Window>
后臺代碼
using System; using System.Windows; using System.Windows.Controls.Primitives; using System.Windows.Threading; namespace ProgressBar { /// <summary> /// MainWindow.xaml 的交互邏輯 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private delegate void UpdateProgressBarDelegate(DependencyProperty dp, object value); private void Button_Click(object sender, RoutedEventArgs e) { UpdateProgressBarDelegate updateProgressBaDelegate = new UpdateProgressBarDelegate(progressBar.SetValue); for (int i = (int)progressBar.Minimum; i <= (int)progressBar.Maximum; i++) { Dispatcher.Invoke(updateProgressBaDelegate, DispatcherPriority.Background, new object[] { RangeBase.ValueProperty, Convert.ToDouble(i) }); } } } }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Asp.net使用SignalR實(shí)現(xiàn)酷炫端對端聊天功能
這篇文章主要為大家詳細(xì)介紹了Asp.net使用SignalR實(shí)現(xiàn)酷炫端對端聊天功能,感興趣的小伙伴們可以參考一下2016-04-04sqlserver 批量數(shù)據(jù)替換助手V1.0版發(fā)布
前段時間網(wǎng)站被掛馬,數(shù)據(jù)庫表中很多文本字段都被加上了一段js腳本。修復(fù)完程序漏洞之后便開始著手清理這些被注入的數(shù)據(jù),其間參考了一些網(wǎng)上的方法,大都是寫一個存儲過程進(jìn)行一個表一個表逐一清理。2011-10-10asp.net訪問網(wǎng)絡(luò)路徑方法(模擬用戶登錄)
這篇文章主要介紹了asp.net訪問網(wǎng)絡(luò)路徑方法,其實(shí)就是模擬用戶登錄,需要的朋友可以參考下2014-08-08