ProgressBar 背景属性在 Windows 应用商店应用程序中不起作用

Sch*_*Box 2 xaml progress-bar windows-store-apps windows-8.1 windows-phone-8.1

ProgressBar在我的应用程序中添加了一个,我希望它有一个透明的背景,所以我这样做了:

<ProgressBar IsIndeterminate="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
    <ProgressBar.Background>
        <SolidColorBrush Color="Black" Opacity="0.5" />
    </ProgressBar.Background>
</ProgressBar>
Run Code Online (Sandbox Code Playgroud)

在预览窗口中,一切看起来都很好,但是,当我运行我的应用程序时,它Background根本不存在。我找到的解决方案是将 放在ProgressBarGrid 中并Background在 中设置属性Grid,但由于预览显示它是正确的,并且属性在那里,它不应该工作吗?
更新:

根据@Chris W.的建议,我尝试覆盖ProgressBar元素的默认样式,如下所示:

<ProgressBar IsIndeterminate="True" Background="#FF000000" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="50">
    <ProgressBar.Style>
        <Style TargetType="ProgressBar">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ProgressBar">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Indeterminate">
                                        <Storyboard RepeatBehavior="Forever">
                                            <DoubleAnimation Storyboard.TargetName="DeterminateRoot"
                                                 Storyboard.TargetProperty="Opacity"
                                                 To="0.5"
                                                 Duration="0" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </ProgressBar.Style>
</ProgressBar>
Run Code Online (Sandbox Code Playgroud)

但仍然没有果汁。

Chu*_*are 5

需要删除两 (2) 个故事板动画

文档大纲 > 右键单击​​进度栏 > 编辑模板 -> 编辑副本

<!--
<FadeOutThemeAnimation Storyboard.TargetName="DeterminateRoot"/>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DeterminateRoot"/>
-->
Run Code Online (Sandbox Code Playgroud)

正如@ricochete建议的那样,如果使用 Opacity = 1,则将确定根的 Z 顺序更改为位于 EllipseGrid 的顶部

<!--
<FadeOutThemeAnimation Storyboard.TargetName="DeterminateRoot"/>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DeterminateRoot"/>
-->
Run Code Online (Sandbox Code Playgroud)
<Border x:Name="DeterminateRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" MinHeight="{TemplateBinding MinHeight}">
    <Rectangle x:Name="ProgressBarIndicator" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Left" Margin="{TemplateBinding Padding}"/>
</Border>
<Grid x:Name="EllipseGrid" Opacity="0">
<!-- ... more XAML Style -->
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述