Doe的任何人都知道下面的标记有什么问题
<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>
一切看起来都不错但不起作用:(( Doe的silverlight知道如何为canvas.top和canvas.left制作动画? 或者也许我错过了什么?
答案 0 :(得分:4)
你需要一个画布对象。用画布替换网格。
答案 1 :(得分:2)
Canvas.Top和Canvas.Left附加属性仅在Rectangle(或UIElement)托管在Canvas面板中时使用。 Grid使用不同的逻辑和附加属性来布局它的子项。