WPF使用ProgressBar的简单方法

好久没写文章了,今天刚用到WPF的进度条,百度搜了下方法特来记录下。

        private void beginImport()
        {
            pro.Maximum = 100;//pro是ProgressBar的命名
            pro.Value = 0;

            for (int i = 0; i < 100; i++)
            {
                Dispatcher.Invoke(new Action<System.Windows.DependencyProperty, object>(pro.SetValue), System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty ,Convert.ToDouble(i + 1) });  
            }
        }

猜你喜欢

转载自blog.csdn.net/qq_33459369/article/details/83411040
今日推荐