2011-06-08 73 views
1

Doe的人知道是什么毛病标记下面Silverlight动画问题

<UserControl 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    x:Class="DoubleAnim.MainPage" 
    Width="640" Height="480"> 
    <UserControl.Resources> 
     <Storyboard x:Name="Storyboard1"> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="objectToAnimate"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:1" Value="400"/> 
      </DoubleAnimationUsingKeyFrames>     
     </Storyboard> 
    </UserControl.Resources> 

    <Grid x:Name="LayoutRoot" Background="White"> 
     <Rectangle x:Name="objectToAnimate" Fill="#FF0000F9" HorizontalAlignment="Left" Canvas.Top="164" Height="100" Stroke="Black" VerticalAlignment="Top" Width="192" RadiusY="8" RadiusX="8" > 
     </Rectangle> 
     <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="132,180,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> 
    </Grid> 
</UserControl> 

一切看起来不错,但它不是工作:(( 母鹿的Silverlight知道如何动画canvas.top和canvas.left 或者,也许是什么?我错过了什么?

回答

4

你需要一个Canvas对象。用帆布替换网格。

2

Canvas.TopCanvas.Left附加属性都仅在使用矩形(或的UIElement)托管在Canvas面板中。 Grid使用不同的逻辑和附加的属性来布置它的孩子。

+0

THANX GUYS!我没有提及此! – magic987 2011-06-09 11:34:00