我试图移动画布中绘制的矩形。当我运行我的代码时,我得到一个错误,基本上是“Canvas”。“Top”不是受支持的属性。有什么想法吗?提前谢谢。
这是我的代码:
<Window.Resources>
<ResourceDictionary>
<Storyboard x:Key="MoveRect">
<DoubleAnimation Storyboard.TargetName="box" Storyboard.TargetProperty="Canvas.Top"
From="0" To="100" Duration="0:0:1"/>
</Storyboard>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Canvas Grid.Row="0" Width="200" Height="200" HorizontalAlignment="Left">
<Rectangle x:Name="box" Width="100" Height="100" Fill="LightBlue" Stroke="DarkBlue" StrokeThickness="3"
Canvas.Top="0" Canvas.Left="0"/>
</Canvas>
<Button Grid.Row="1" Content="Move" Width="100" HorizontalAlignment="Left" Click="Button_Click"/>
</Grid>