• 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>

  • 相关阅读:
    IDEA调试快捷键
    视频预览
    文件上传:简单的demo
    Java 运行时优化
    Java 类加载
    Java StringTable
    Java 为什么不用Vector
    C++ 查找函数
    JVM 垃圾回收
    JVM 直接内存
  • 原文地址:https://www.cnblogs.com/xiehaha123/p/11662050.html
Copyright © 2020-2023  润新知