• WPF 进度条


    一:简单常见

    //window1.xaml
    <Window x:Class="progressbartest.Window1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Window1" Height="217" Width="300">
        <Grid>
            <ProgressBar Height="24" HorizontalAlignment="Left" Margin="12,72,0,0" Name="progressBar1" VerticalAlignment="Top" Width="254" Foreground="#FF2EAFF1" />
        </Grid>
    </Window>


    //window1.xaml.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.Shapes;
    using System.Threading;
    
    namespace progressbartest
    {
        /// <summary>
        /// Window1.xaml 的交互逻辑
        /// </summary>
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
    
                ProgressBegin();
    
            }
    
            private void ProgressBegin()
            {
    
                Thread thread = new Thread(new ThreadStart(() =>
                {
                    for (int i = 0; i <= 100; i++)
                    {
                        this.progressBar1.Dispatcher.BeginInvoke((ThreadStart)delegate { this.progressBar1.Value = i; });
                        Thread.Sleep(100);
                    }
    
                }));
                thread.Start();
            }
    
        }
    }
    

      效果图:

     二:斜纹渐变滚动条

    https://www.cnblogs.com/lonelyxmas/p/10716917.html

    三:类似于系统麦克风音量大小检测效果

    <ListView x:Name="SpeakerPrograssListview" ItemContainerStyle="{StaticResource customProgressView}" ItemsSource="{Binding list1}"     HorizontalAlignment="Stretch" BorderThickness="0" Margin="12,0,0,0" Background="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Disabled"     ScrollViewer.VerticalScrollBarVisibility="Disabled">
      <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
        <WrapPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" Background="Transparent" IsItemsHost="True">
        </WrapPanel>
        </ItemsPanelTemplate>
      </ItemsControl.ItemsPanel>
    </ListView>

    <Style TargetType="ListViewItem" x:Key="customProgressView">
      <Setter Property="Template">
      <Setter.Value>
      <ControlTemplate TargetType="ListViewItem">
      <Grid Margin="3,0,3,0">
        <ProgressBar x:Name="proBar" Style="{DynamicResource SimpleProgressBar}" Maximum="10" Minimum="0" Width="6" Height="15" Background="#F2F3F7"   Foreground="#329FEE" Value="{Binding progressValue}" BorderBrush="Transparent" BorderThickness="0"></ProgressBar>
      </Grid>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    <Style TargetType="ProgressBar" x:Key="SimpleProgressBar">
    <Setter Property="Background" Value="#F2F3F7" />
    <Setter Property="Maximum" Value="1" />
    <Setter Property="Value" Value="0" />
    <Setter Property="Height" Value="10" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="Foreground" Value="#329FEE" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="ProgressBar">
    <Grid x:Name="Root" >
    <Border x:Name="PART_Track" Background="{TemplateBinding Background}"
    CornerRadius="0"
    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    <Border x:Name="PART_Indicator" HorizontalAlignment="Left" Background="{TemplateBinding Foreground}"
    CornerRadius="0"
    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    </Grid>
    <ControlTemplate.Triggers>
    <Trigger Property="Orientation" Value="Vertical">
    <Setter Property="LayoutTransform" TargetName="Root" >
    <Setter.Value>
    <RotateTransform Angle="-90" />
    </Setter.Value>
    </Setter>
    </Trigger>
    </ControlTemplate.Triggers>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    四:复杂的效果

    https://www.cnblogs.com/dathlin/p/8150516.html

  • 相关阅读:
    第二周例行报告
    洛谷 P3384 【模板】轻重链剖分
    洛谷 P3380 【模板】二逼平衡树(树套树)
    洛谷 P4568 [JLOI2011]飞行路线
    2018 ICPC Asia Nanjing Regional Preliminary L. Magical Girl Haze
    牛客 2020 牛客国庆集训派对 day8 G. Shuffle Cards
    洛谷 P3224 [HNOI2012]永无乡
    洛谷 P1486 [NOI2004]郁闷的出纳员
    洛谷 P3391 【模板】文艺平衡树
    洛谷 P3369 【模板】普通平衡树
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/12713669.html
Copyright © 2020-2023  润新知