Reputation: 31
I created the following Storyboard with Blend, if I run it in Blend it works. If I try to run it in Runtime I get the following exception
"The value of the 'Children' property in the path '(0).(1)[3].(2)' points to an immutable instance of 'System.Windows.Media.TransformCollection'."
Below is the XAML part
<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>
This is in the code behind the Window
Storyboard storyboard = (Storyboard)FindResource("Storyboard1");
storyboard.Begin();
I expected it to work
Upvotes: 0
Views: 20
Reputation: 31
I solved the problem by removing the TransformGroup.Children by transforming the code like this:
<Window.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Placeholder" Storyboard.TargetProperty="(UIElement.RenderTransform).(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).(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>
and now the code no longer produces exceptions
Upvotes: 0