Почему эта анимация не работает? - PullRequest
2 голосов
/ 18 сентября 2010

Что не так в этом коде?

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" mc:Ignorable="d"
    x:Class="SimpleStoryBoard.MainPage"
    Width="640" Height="480">
    <UserControl.Resources>
        <Storyboard x:Name="SampleStoryboard">
            <DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).
(TransformGroup.Children)[0].(TranslateTransform.X)"
Storyboard.TargetName="rectangle">
                <EasingDoubleKeyFrame KeyTime="0:0:1"
Value="152.517"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).
(TransformGroup.Children)[0].(TranslateTransform.Y)"
Storyboard.TargetName="rectangle">
                <EasingDoubleKeyFrame KeyTime="0:0:1"
Value="27.66"/>
            </DoubleAnimationUsingKeyFrames>
            <ColorAnimationUsingKeyFrames
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
Storyboard.TargetName="rectangle">
                <EasingColorKeyFrame KeyTime="0:0:1"
Value="#FFF11212"/>
            </ColorAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).
(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
Storyboard.TargetName="rectangle">
                <EasingDoubleKeyFrame KeyTime="0:0:1"
Value="1.424"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).
(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
Storyboard.TargetName="rectangle">
                <EasingDoubleKeyFrame KeyTime="0:0:1"
Value="1.88"/>
            </DoubleAnimationUsingKeyFrames>
            <PointAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)"
Storyboard.TargetName="rectangle">
                <EasingPointKeyFrame KeyTime="0:0:1"
Value="0.809,0.202"/>
            </PointAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <i:Interaction.Triggers>
            <i:EventTrigger>
                <ei:ControlStoryboardAction Storyboard="{StaticResource SampleStoryboard}"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
        <Rectangle Height="151" HorizontalAlignment="Left" Margin="93,86,0,0" Name="rectangle" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="330">
            <Rectangle.RenderTransform>
                <CompositeTransform/>
            </Rectangle.RenderTransform>
        </Rectangle>
    </Grid>
</UserControl>

Я получаю ошибку около (UIElement.RenderTransform). (TransformGroup.Children)[0].(ScaleTransform.ScaleY) как исключение InvalidOperationException. Не удается разрешить целевое свойство

Что означает [0] в приведенном выше примере?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...