Wpf IsIndeterminate进度条模板

Wpf IsIndeterminate进度条模板,wpf,xaml,progress-bar,Wpf,Xaml,Progress Bar,我得到了以下ProgressBar样式: <Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}"> <Setter Property="Background" Value="{StaticResource ControlBackground}" /> <Setter Property="BorderBrush" Value="{StaticResource Activ

我得到了以下
ProgressBar
样式:

<Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}">
    <Setter Property="Background" Value="{StaticResource ControlBackground}" />
    <Setter Property="BorderBrush" Value="{StaticResource ActiveControlBorderBrush}" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="MinHeight" Value="23" />
    <Setter Property="MinWidth" Value="75" />
    <Setter Property="OverridesDefaultStyle" Value="True" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ProgressBar}">
                <Grid MinHeight="{TemplateBinding MinHeight}"
                      MinWidth="{TemplateBinding MinWidth}">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Determinate" />
                            <VisualState x:Name="Indeterminate">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="00:00:00"
                                             Storyboard.TargetName="PART_Indicator"
                                             Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                            <DiscreteObjectKeyFrame.Value>
                                                <SolidColorBrush>Transparent</SolidColorBrush>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Border x:Name="PART_Track"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}" />
                    <Border x:Name="PART_Indicator"
                            Background="{TemplateBinding BorderBrush}" 
                            HorizontalAlignment="Left" />
                    <Grid x:Name="Animation" ClipToBounds="True">
                        <Border x:Name="PART_GlowRect"
                                Width="100"
                                Background="{StaticResource ActiveControlBorderBrush}"
                                HorizontalAlignment="Left"
                                Margin="-100,0,0,0" />
                    </Grid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

透明的
如果我在
ProgressBar
上将
isindestime
设置为
True
;我可以看到
指示器
设计器
中移动,但不能在
运行时
上移动。有人知道它为什么不能在运行时运行吗

编辑:


使用Visual Studio Professional 2012/应用程序是WPF.NET 3.5

我尝试了您的示例,它似乎很有效。检查:

  • StaticResources发现正确,我用黑色代替ActiveControlBorderBrush,用绿色代替ControlBackground

  • 如果从代码中显示,请检查可能的线程问题(可以是frezee或smth)


  • 空的
    窗口
    ,只有
    进度条
    资源字典中的此样式
    。窗户没有结冰。奇怪的是;它在designer中工作。好吧,一个愚蠢的问题:是否将IsIntermediate属性设置为true?:)没有这种风格行得通吗?是的:)ofc已经定了。正如我所说;它在
    设计器
    中工作,但在
    运行时
    中不工作。已尝试将样式移出
    资源字典
    。尝试将
    VSM
    替换为
    触发器
    。没有
    样式的默认
    progressbar
    正在工作。这很奇怪,因为我看到它在为我工作。我在WPF 4.0中使用了VS 2012,您可以尝试使用不同的.NET版本检查此问题。