具有多种颜色的进度条 WPF
Progressbar with multiple colors WPF
我正在尝试让我的进度条看起来像这样:
但我有这个:
这是我的代码(我使用指标的 属性 "fill" 为进度条创建了一个样式):
<Rectangle x:Name="Indicator" >
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0,0" StartPoint="1,0">
<GradientStop Color="Red" Offset="0"/>
<GradientStop Color="Yellow" Offset="0.5"/>
<GradientStop Color="Green" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
欢迎来到 SO!
只需将该指示器的宽度设置为与父 ProgressBar 的宽度相同:
<Rectangle x:Name="Indicator" Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=ProgressBar}}">
简单!
我正在尝试让我的进度条看起来像这样:
但我有这个:
这是我的代码(我使用指标的 属性 "fill" 为进度条创建了一个样式):
<Rectangle x:Name="Indicator" >
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0,0" StartPoint="1,0">
<GradientStop Color="Red" Offset="0"/>
<GradientStop Color="Yellow" Offset="0.5"/>
<GradientStop Color="Green" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
欢迎来到 SO!
只需将该指示器的宽度设置为与父 ProgressBar 的宽度相同:
<Rectangle x:Name="Indicator" Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=ProgressBar}}">
简单!