为什么这个动画不起作用?

时间:2010-09-18 10:14:29

标签: silverlight-4.0

此代码有什么问题?

<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]表示什么?

0 个答案:

没有答案