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(pro.SetValue), System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty ,Convert.ToDouble(i + 1) });  
            }
        }

 

你可能感兴趣的:(WPF)