有没有办法让默认进度条成为垂直进度条?

时间:2018-03-20 08:14:55

标签: c# xaml uwp

我希望有一个进度条,而不是从左到右,从下到上填充。是否有任何属性或某种方法可以将UWP控件提供的默认进度条转换为垂直进度条?

*编辑 Image

了解如何应用rendertransform - 进度条流出网格。

这是代码!

<StackPanel Background="{StaticResource SystemControlAcrylicWindowBrush}" Padding="40">

    <Grid BorderBrush="Black" BorderThickness="1,1,1,1" Width="220" Height="200">
        <ProgressBar HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5"
                     Value="60">
            <ProgressBar.RenderTransform>
                <CompositeTransform Rotation="0"/>
            </ProgressBar.RenderTransform>
        </ProgressBar>
    </Grid>

    <Grid BorderBrush="Black" BorderThickness="1,1,1,1" Width="220" Height="200" Margin="40">
        <ProgressBar HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5"
                     Value="60">
            <ProgressBar.RenderTransform>
                <CompositeTransform Rotation="-90"/>
            </ProgressBar.RenderTransform>
        </ProgressBar>
    </Grid>

</StackPanel>

Image

仍然没有固定,确实是宽度和高度!

Image

删除了边距和填充,仍然无效!

1 个答案:

答案 0 :(得分:4)

UWP ProgressBar没有Orientation属性。您无法在UWP中使用progbar.Orientation = Orientation.Horizontal;。如果你想放置 垂直ProgressBar,您可以使用RenderTransform来实现它。

<ProgressBar RenderTransformOrigin="0.5,0.5" 
             Maximum="200" 
             Value="50" 
             Width="200" 
             Background="LightGray"
             Foreground="Green"
             VerticalAlignment="Center" 
             HorizontalAlignment="Center">
    <ProgressBar.RenderTransform>
        <CompositeTransform Rotation="-90" />
    </ProgressBar.RenderTransform>
</ProgressBar>