先来看一下效果图,这个是没有计数的进度条

这个是带计数的进度条

进度条的封装,首先是进度窗口的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="Cancel" Name="BnCancle" Visibility="{Binding ElementName=window,Path=IsCanCancel}">
<Button.Resources>
<Style TargetType="{x:Type Button}">

该博客介绍了如何在WPF中创建一个覆盖窗口的进度条,包括无计数和带计数两种展示方式,并提供了进度窗口的XAML代码示例。
最低0.47元/天 解锁文章
2814

被折叠的 条评论
为什么被折叠?



