本质上,当进度条值为100时,您希望应用一个不同的模板,也就是仅显示进度条时的模板。使用以下XAML:
<Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid MinHeight="14" MinWidth="200">
<Border Name="PART_Track"
CornerRadius="5,0,0,5"
Background="{DynamicResource ProgressBarBackgroundColor}"
BorderBrush="{DynamicResource ProgressBarBackgroundColor}"
BorderThickness="0" />
<Border Name="PART_Indicator"
CornerRadius="5"
Background="{DynamicResource ProgressBarFillBackgroundColor}"
BorderBrush="{DynamicResource ProgressBarFillBackgroundColor}"
BorderThickness="0"
HorizontalAlignment="Left" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Value" Value="100">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid MinHeight="14" MinWidth="200">
<Border Name="PART_Track"
CornerRadius="5,0,0,5"
Background="{DynamicResource ProgressBarBackgroundColor}"
BorderBrush="{DynamicResource ProgressBarBackgroundColor}"
BorderThickness="0" />
<Border Name="PART_Indicator"
CornerRadius="5,0,0,5"
Background="{DynamicResource ProgressBarFillBackgroundColor}"
BorderBrush="{DynamicResource ProgressBarFillBackgroundColor}"
BorderThickness="0"
HorizontalAlignment="Left" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>