Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我无法解析WPF应用程序中Storyboard.TargetProperty的路径_C#_.net_Wpf_Xaml_Wpf Animation - Fatal编程技术网

C# 我无法解析WPF应用程序中Storyboard.TargetProperty的路径

C# 我无法解析WPF应用程序中Storyboard.TargetProperty的路径,c#,.net,wpf,xaml,wpf-animation,C#,.net,Wpf,Xaml,Wpf Animation,在我的WPF应用程序中,我有一个特定元素的动画。要设置动画的元素如下所示 LineGeometry元素的颜色应该设置动画,但我不知道如何解析Storyboard.TargetProperty路径。在这种情况下,GeometryGroup元素会导致问题。如何将GeometryGroup元素容纳在故事板的路径中。TargetProperty,请参见三个“?” 我已经尝试了以下方法: ..).GeometryGroup.(…)。(GeometryGroup.Children.(…).Geometr

在我的WPF应用程序中,我有一个特定元素的动画。要设置动画的元素如下所示


LineGeometry
元素的颜色应该设置动画,但我不知道如何解析
Storyboard.TargetProperty
路径。在这种情况下,
GeometryGroup
元素会导致问题。如何将
GeometryGroup
元素容纳在
故事板的路径中。TargetProperty
,请参见三个“?”

我已经尝试了以下方法:
..).GeometryGroup.(…
)。(GeometryGroup.Children.(…
).GeometryCollection.(…
)。我也尝试过
(Path.Stroke)。(solidcolorbush.Color)


几何体元素是带有数据绑定的
ItemsControl
DataTemplat
的一部分。我在通过数据绑定链接的.NET属性上遇到了一个异常

例外情况的翻译:

System.InvalidOperationException:“无法解析属性路径”(0).GeometryGroup.(1)“中的所有属性引用。请确保适当的对象支持这些属性。”

在应用程序中有一个类似的元素,
EllipseGeometry
,其中动画以这种方式工作。区别在于
GeometryGroup
元素



非常感谢您的帮助。

注意,在工作示例中,您将透明笔刷设置为“笔划”属性。
但在第一个示例中,此属性未设置任何内容。
因此它是空的。
并且null没有设置动画的属性

您可以在此属性中显式设置SolidColorBrush实例,为该实例命名,并直接访问其颜色属性。
这比所有这些演员都要容易得多

例如:

        <Path x:Name="theX" StrokeThickness="7" StrokeStartLineCap="Round" StrokeEndLineCap="Round">
            <Path.Stroke>
                <SolidColorBrush x:Name="PathStroke" Color="Transparent"/>
            </Path.Stroke>
            <Path.Data>
                <GeometryGroup>
                    <LineGeometry StartPoint="4, 4" EndPoint="60, 60"/>
                    <LineGeometry StartPoint="4, 60" EndPoint="60, 4"/>
                </GeometryGroup>
            </Path.Data>
        </Path>



看看你的动画效果。你正在使用路径。这有填充和笔划,它们是画笔。乍一看,删除这些问号看起来可能有用。@Andy谢谢你的评论,但这不起作用。我在写动画时已经试过了。我将尝试将其添加到问题中。
(路径.笔划)。(SolidColorBrush.Color)
-如果path.Stroke属性包含未冻结的SolidColorBrush实例,则此路径将起作用。根据您的解释,不清楚您在那里有什么。非常感谢,它起作用。我无法对答案进行评分,因为我没有足够的信誉点。这不重要。主要的事情对您有所帮助。
        <ColorAnimationUsingKeyFrames BeginTime="0:0:1"
                                      Duration="0:0:1"
                                      Storyboard.TargetName="PathStroke"
                                      Storyboard.TargetProperty="Color"
                                      FillBehavior="Stop">
            <DiscreteColorKeyFrame Value="#333333" KeyTime="0:0:0"/>
            <LinearColorKeyFrame Value="#6AFF00" KeyTime="0:0:0.2"/>
            <DiscreteColorKeyFrame Value="#6AFF00" KeyTime="0:0:0.5"/>
            <LinearColorKeyFrame Value="#333333" KeyTime="0:0:0.9"/>
        </ColorAnimationUsingKeyFrames>