WPF两侧圆角进度条ProgressBar

WPF两侧圆角进度条ProgressBar

xaml样式

<Style x:Key="ProgressBarStyle" TargetType="{x:Type ProgressBar}">
            <Setter Property="Foreground" Value="#F2F2F2"/>
            <Setter Property="Background" Value="White"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Width" Value="60"/>
            <Setter Property="Height" Value="30"/>
            <Setter Property="Value" Value="{Binding ProgressValue}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ProgressBar}">
                        <Grid  x:Name="Root" >
                            <Border Height="30" Width="60" Background="Transparent" BorderBrush="#1C7FFF" BorderThickness="1" CornerRadius="17"  FocusVisualStyle="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Center">
                                <Rectangle HorizontalAlignment="Left" Width="{Binding ProgressValue}" Fill="#C7DBF5" >
                                    <Rectangle.Clip>
                                        <RectangleGeometry Rect="0,0,58,28"  RadiusY="18" RadiusX="18"/>
                                    </Rectangle.Clip>
                                </Rectangle>
                            </Border>
                            <TextBlock Foreground="#4796FC" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding PCT}" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="Orientation" Value="Vertical">
                                <Setter Property="LayoutTransform" TargetName="Root" >
                                    <Setter.Value>
                                        <RotateTransform Angle="-90" />
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

调用

<ProgressBar Style="{StaticResource ProgressBarStyle}" x:Name="prob" Value="{Binding ProgressValue}"  Visibility="{Binding VisDownloadProgress}" Background="White" Foreground="#F2F2F2" VerticalAlignment="Center" Margin="0,0,20,0"/>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值