WPF 进度条的样式

WPF 进度条的样式
作者:邱名涛
撰写时间:2019 年 7 月 28 日
前台:

  <ProgressBar Name="progressBar" Minimum="1" Maximum="1000" Height="20" VerticalAlignment="Bottom"/>
            <Button Content="Done" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="20" Margin="122,0,124,20" Click="Button_Click"/>

后台:

using System;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Threading;

namespace WpfApp1
{
    /// <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) });
            }
        }
    }

}

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值