为了账号安全,请及时绑定邮箱和手机立即绑定

用c# progressBar 控件实现进度条红绿蓝三种颜色渐变

用c# progressBar 控件实现进度条红绿蓝三种颜色渐变

C#
柔情似水的眼眸3611166 2017-05-08 17:06:46
.cs源码using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using System.Threading;namespace 进度条显示{    /// <summary>    /// MainWindow.xaml 的交互逻辑    /// </summary>    public partial class MainWindow : Window    {        public MainWindow()        {            InitializeComponent();        }        private delegate void A(System.Windows.DependencyProperty dp, object value);        private void process()        {            pro.Minimum = 0;            pro.Maximum = 10000;            pro.Value = 0;            double x = 0;            A update = new A(pro.SetValue);            do            {                x = x + 1;                Dispatcher.Invoke(update, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, x });                lab.Content= (pro.Value * 100 / pro.Maximum).ToString()+"%";                            } while (pro.Value != pro.Maximum);          }        private void button1_Click(object sender, RoutedEventArgs e)        {            process();            pro.Foreground=        }    }}xaml源码<Window x:Class="进度条显示.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="MainWindow" Height="350" Width="525">    <Grid>        <Button Content="start" Height="23" HorizontalAlignment="Left" Margin="175,160,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />        <Label Height="28" HorizontalAlignment="Left" Margin="441,81,0,0" Name="lab" VerticalAlignment="Top" />        <ProgressBar Height="30" HorizontalAlignment="Left" Margin="97,79,0,0" Name="pro" VerticalAlignment="Top" Width="313" />    </Grid></Window>
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 6303 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信