Doe's anybody knows what wrong with markup below
<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"开发者_如何学Python Height="23" HorizontalAlignment="Left" Margin="132,180,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
</Grid>
</UserControl>
Everything looks good but it not works:(( Doe's silverlight know how to animate canvas.top and canvas.left? Or maybe that I have missed something?
You need a canvas object. Replace Grid with Canvas.
The Canvas.Top and Canvas.Left attached properties are only used if the Rectangle (or UIElement) is hosted in a Canvas panel. The Grid uses different logic and attached properties to layout it's children.
精彩评论