WPF主题错误:无法解析属性路径中的所有属性引用

时间:2014-08-29 10:59:53

标签: wpf themes

我在WPF主题上遇到了一个奇怪的错误:Cannot resolve all property references in the property path '(0).(1).(2)[0].X' 我已将其追溯到我的进度栏了。

    <Style x:Key="ProgressBarStyle"
       TargetType="{x:Type ProgressBar}">
    <Setter Property="Foreground"
            Value="{StaticResource ProgressBarForegroundBrush}" />
    <Setter Property="Background"
            Value="{StaticResource ProgressBarBackgroundBrush}" />
    <Setter Property="BorderThickness"
            Value="0" />
    <Setter Property="Height"
            Value="6" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ProgressBar}">
                <Grid x:Name="TemplateRoot"
                      SnapsToDevicePixels="true">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Determinate" />
                            <VisualState x:Name="Indeterminate">
                                <Storyboard RepeatBehavior="Forever">
                                    <DoubleAnimation Duration="00:00:.5"
                                                     From="0"
                                                     To="20"
                                                     Storyboard.TargetProperty="(Shape.Fill).(LinearGradientBrush.Transform).(TransformGroup.Children)[0].X"
                                                     Storyboard.TargetName="IndeterminateGradientFill" />
                                    </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Border x:Name="ProgressBarTrack"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}" />
                    <Rectangle x:Name="PART_Track"
                               Margin="{TemplateBinding BorderThickness}" />
                    <Decorator x:Name="PART_Indicator"
                               HorizontalAlignment="Left"
                               Margin="{TemplateBinding BorderThickness}">
                        <Grid x:Name="Foreground">
                            <Rectangle x:Name="Indicator"
                                       Fill="{TemplateBinding Foreground}" />
                        </Grid>
                    </Decorator>
                    <Grid x:Name="IndeterminateRoot"
                          Visibility="Collapsed">
                        <Rectangle x:Name="IndeterminateSolidFill"
                                   Fill="{TemplateBinding Foreground}"
                                   Margin="{TemplateBinding BorderThickness}"
                                   Opacity="1"
                                   RenderTransformOrigin="0.5,0.5"
                                   StrokeThickness="0" />
                        <Rectangle x:Name="IndeterminateGradientFill"
                                   Fill="{StaticResource ProgressBarIndeterminateBackgroundBrush}"
                                   Margin="{TemplateBinding BorderThickness}"
                                   StrokeThickness="1" />
                    </Grid>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="Orientation"
                             Value="Vertical">
                        <Setter Property="LayoutTransform"
                                TargetName="TemplateRoot">
                            <Setter.Value>
                                <RotateTransform Angle="-90" />
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                    <Trigger Property="IsIndeterminate"
                             Value="true">
                        <Setter Property="Visibility"
                                TargetName="Indicator"
                                Value="Collapsed" />
                        <Setter Property="Visibility"
                                TargetName="IndeterminateRoot"
                                Value="Visible" />
                    </Trigger>
                    <Trigger Property="IsIndeterminate"
                             Value="false">
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<SolidColorBrush x:Key="ProgressBarBackgroundBrush"
                 Color="{StaticResource Color_005}" />
<SolidColorBrush x:Key="ProgressBarForegroundBrush"
                 Color="{StaticResource Color_024}" />
<LinearGradientBrush x:Key="ProgressBarIndeterminateBackgroundBrush"
                     EndPoint="0,1"
                     MappingMode="Absolute"
                     SpreadMethod="Repeat"
                     StartPoint="20,1"
                     Opacity="0.8">
    <LinearGradientBrush.Transform>
        <TransformGroup>
            <TranslateTransform X="0" />
            <SkewTransform AngleX="-30" />
        </TransformGroup>
    </LinearGradientBrush.Transform>
    <GradientStop Color="{StaticResource Color_023}"
                  Offset="0.249" />
    <GradientStop Color="{StaticResource Color_024}"
                  Offset=".25" />
    <GradientStop Color="{StaticResource Color_024}"
                  Offset="0.75" />
    <GradientStop Color="{StaticResource Color_023}"
                  Offset="0.751" />
</LinearGradientBrush>

现在我可以看到DoubleAnimation.Storyboard.TargetProperty以及对LinearGradientBrush ProgressBarIndeterminateBackgroundBrush转换的引用。但它看起来不错#39;我对你的理解很明显!

1 个答案:

答案 0 :(得分:2)

我能够重现您的情况,只需将(Shape.Fill)更改为(Rectangle.Fill)似乎就可以解决问题。