运行时的故事板异常

问题描述 投票:0回答:1

我用 Blend 创建了以下故事板,如果我在 Blend 中运行它,它就可以工作。如果我尝试在运行时运行它,我会收到以下异常

"The value of the 'Children' property in the path '(0).(1)[3].(2)' points to an immutable instance of 'System.Windows.Media.TransformCollection'."

下面是XAML部分

    <Window.Resources>
        <Storyboard x:Key="Storyboard1">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Placeholder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="90"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.3000000" Value="100"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.6000000" Value="200"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Placeholder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                <EasingDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="2"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.6000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>
                <Border x:Name="Placeholder"
                        RenderTransformOrigin="0.5,0.5"
                        Style="{StaticResource NavPlaceholderStyle}">
                    <Border.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Border.RenderTransform>
                </Border>

这是在窗口后面的代码中

Storyboard storyboard = (Storyboard)FindResource("Storyboard1");
storyboard.Begin();

我希望它能起作用

storyboard
1个回答
0
投票
per

© www.soinside.com 2019 - 2024. All rights reserved.