Wpf圆角进度条

本文关键字:圆角 Wpf | 更新日期: 2023-09-27 18:10:55

我想做一个简单的圆角进度条。

这是我的xaml:
 <Grid>
    <ProgressBar Minimum="0" Maximum="100"  Height="50"  Value="50" Name="pbStatus" BorderBrush="Black" BorderThickness="3" Foreground="#336699"  />
    <TextBlock Text="{Binding ElementName=pbStatus, Path=Value, StringFormat={}{0:0}%}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>

我正试图寻找Border-Radius属性....但我就是找到了。请帮忙好吗?

谢谢。

Wpf圆角进度条

From Visual Studio Designer右键单击ProgressBar>编辑模板>编辑副本,在生成样式中,将CornerRadius添加到Border,并在填充矩形中设置RadiusXRadiusY:

<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="30"/>
                        <Rectangle x:Name="PART_Track" />
                        <Grid x:Name="PART_Indicator" ClipToBounds="true" HorizontalAlignment="Left">
                            <Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}" RadiusX="30" RadiusY="30"/>
                            <Rectangle x:Name="Animation" Fill="{TemplateBinding Foreground}" RenderTransformOrigin="0.5,0.5" RadiusX="30" RadiusY="30">
                                <Rectangle.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform/>
                                        <SkewTransform/>
                                        <RotateTransform/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </Rectangle.RenderTransform>
                            </Rectangle>
                        </Grid>

在内部设置边框,并设置边框的角半径属性。这是描述它的链接进度条样式右半径