介绍
这期内容当中小编将会给大家带来有关利用WPF怎么实现一个进度条功能,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
实现说明
1,下载梅相关代码或者dll文件;
2,工程中引入该dll,并引入其资源文件;
& lt; Application.Resources> ,,,,,,,& lt; ResourceDictionary> ,,,,,,,,,,,& lt; ResourceDictionary.MergedDictionaries> ,,,,,,,,,,,,,,,& lt; ResourceDictionary 源=?FirstFloor.ModernUI;组件/资产/ModernUI.xaml",/比; ,,,,,,,,,,,,,,,& lt; ResourceDictionary 源=?FirstFloor.ModernUI;组件/资产/ModernUI.Light.xaml"/比; ,,,,,,,,,,,& lt;/ResourceDictionary.MergedDictionaries> ,,,,,,,& lt;/ResourceDictionary> ,,,& lt;/Application.Resources>
3,在需要显示进度条的页面,加入控件(其实还是WPF控件,只是梅扩展了其样式而已);
& lt; Label 利润率=?280169年,0,0“,风格=皗StaticResource BackGroundContentText}“, x: Name=發blMainState", HorizontalAlignment=癓eft", VerticalAlignment=癟op"在正在启动:& lt;/Label> ,,,,,,,& lt; ProgressBar 利润率=?280200年,0,0“,HorizontalAlignment=癓eft", VerticalAlignment=癟op",宽度=?00“,最??“,x: Name=癙rogressControlRealValue",最大=?“,https://www.yisu.com/zixun/, Value=" 0.1 "高=?6”IsIndeterminate=" False "/> <标签保证金=" 280212 0 0”风格=" {StaticResource BackGroundContentText}“x: Name=" lblProcess " HorizontalAlignment=白蟆盫erticalAlignment=岸ゼ丁?正在加载地图数据…标签>
4,后台实现,由于要根据情况更新进度文字及进度条的值,所以,这里用到了异步BackgroundWorker(具体可以网上查查相关资料),
using 系统; using System.Collections.Generic; using 来; using 包含; using System.ComponentModel; namespace Monitor.Class {///才能,& lt; summary>///才能,异步操作///才能,& lt;/summary> public 才能;class  CWorker {才能 ,,,///,& lt; summary> ,,,///,对象 ,,,///,& lt;/summary> ,,,private BackgroundWorker backgroundWorker; ,,,///,& lt; summary> ,,,///,后台执行的操作 ,,,///,& lt;/summary> ,,,public Action BackgroundWork {组,得到,,,} ,,,///,& lt; summary> ,,,///,后台任务执行完毕后事件 ,,,///,& lt;/summary> ,,,public event EventHandler, BackgroundWorkerCompleted; ,,,private BackgroundWorkerEventArgs _eventArgs;//异常参数 ,,,///,& lt; summary> ,,,///,构造 ,,,///,& lt;/summary> ,,,public CWorker () ,,,{ ,,,,,_eventArgs =, new BackgroundWorkerEventArgs (); ,,,,,backgroundWorker =, new BackgroundWorker (); ,,,,,backgroundWorker.WorkerReportsProgress =,真的; ,,,,,backgroundWorker.WorkerSupportsCancellation =,真的; ,,,,,backgroundWorker.DoWork +=, new DoWorkEventHandler (backgroundWorker1_DoWork); ,,,,,backgroundWorker.RunWorkerCompleted +=, new RunWorkerCompletedEventHandler (backgroundWorker1_RunWorkerCompleted); ,,,} ,,,///,& lt; summary> ,,,///,开始工作 ,,,///,& lt;/summary> ,,,public void BegionWork () ,,,{ ,,,,,if (backgroundWorker.IsBusy) ,,,,,,,返回; ,,,,,backgroundWorker.RunWorkerAsync (); ,,,} ,,,///,& lt; summary> ,,,///,工作 ,,,///,& lt;/summary> ,,,///,& lt; param name=皊ender"祝辞& lt;/param> null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null 利用WPF怎么实现一个进度条功能