zoukankan      html  css  js  c++  java
  • wpf中的进度条

    今天学了一下进度条很简单有专门的控件progressbar能够解决这个问题,

    xaml里面添加该控件

    cs里面可以添加

    private void beginImport()
    {
    double value = 0;
    double total = 100d;//得到循环次数
    while (value < total)
    {
    double jd = Math.Round(((value + 1) * (pb_import.Maximum / total)), 4);


    pb_import.Dispatcher.Invoke(new Action<System.Windows.DependencyProperty, object>(pb_import.SetValue),
    System.Windows.Threading.DispatcherPriority.Background,
    ProgressBar.ValueProperty,
    jd);
    //这里是加数据或费时的操作,我这里让它挂起300毫秒
    Thread.Sleep(30);
    //txtJD.Text = "当前的进度是:" + (value + 1) + "(实际值)" + jd + "(百分比)";
    value++;
    }
    }

    如何觉得控件不够好看,也可修改样式,我修改的不是很好看!

    <LinearGradientBrush x:Key="g1" StartPoint="0,0" EndPoint="1,1">
    <GradientStop Color="Orange" Offset="0"/>
    <GradientStop Color="Yellow" Offset="0.5"/>
    <GradientStop Color="Orange" Offset="1"/>
    </LinearGradientBrush>
    <Style
    x:Key="Progressbar"
    TargetType="{x:Type ProgressBar}">
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type ProgressBar}">
    <Grid>
    <Border
    Name="PART_Track"
    CornerRadius="6,6,6,6"
    BorderBrush="Black"
    BorderThickness="1" Background="#FF57C7C9"/>
    <Border
    x:Name="PART_Indicator"
    CornerRadius="6,6,6,6"
    BorderBrush="Red"
    BorderThickness="1"
    HorizontalAlignment="Left" >
    <Border.Background>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    <GradientStop Color="Orange" Offset="0"/>
    <GradientStop Color="Yellow" Offset="0.5"/>
    <GradientStop Color="Orange" Offset="1"/>
    </LinearGradientBrush>
    </Border.Background>
    </Border>
    </Grid>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>

  • 相关阅读:
    寻找大富翁
    C++ STL sort()函数用法
    众数
    平方因子
    Hdu 1089 A+B for Input-Output Practice (I)
    Hdu 1090 A+B for Input-Output Practice (II)
    Hdu 1083 Courses
    Hdu 1069 Monkey and Banana
    Hdu 1062 Text Reverse
    Hdu 1068 Girls and Boys
  • 原文地址:https://www.cnblogs.com/xiehaha123/p/11662050.html
Copyright © 2011-2022 走看看