先来看一下效果图,这个是没有计数的进度条
这个是带计数的进度条
进度条的封装,首先是进度窗口的xaml代码
<Window x:Class="System.Windows.Controls.ProgressBarWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="window" ShowInTaskbar="False"
WindowStartupLocation="Manual" WindowStyle="None"
Background="Transparent" AllowsTransparency="True">
<Grid>
<Border Background="White" Opacity="0.7" CornerRadius="10 10 10 10" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding ElementName=window,Path=Text}" FontSize="15"
Margin="80 5 80 5"
TextWrapping="Wrap" TextAlignment="Center"/>
<ProgressBar Margin="80,5,80,5" Height="25" Grid.Row="1"
IsIndeterminate="{Binding ElementName=window,Path=IsIndeterminate}"
Value="{Binding ElementName=window,Path=Value}"
Maximum="{Binding ElementName=window,Path=Maximum}"/>
<Button Grid.Row="2" MaxWidth="120" Click=&