1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
<Canvas x:Name="myCanvas" Width="731" Height="395"> <Canvas.Resources> <Storyboard x:Name="storyboardExpandContract" Completed="storyboardExpandContract_Completed"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="myRectangleAnimate"> <EasingDoubleKeyFrame KeyTime="0" Value="1"/> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="2"/> <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="myRectangleAnimate"> <EasingDoubleKeyFrame KeyTime="0" Value="1"/> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="2"/> <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </Canvas.Resources>
1: 2: 3: 4: 5:
<local:myRectangle x:Name="myRectangleAnimate" Canvas.Left="589" Canvas.Top="232" RenderTransformOrigin="0.5,0.5" Opacity="0"> <local:myRectangle.RenderTransform> <CompositeTransform/> </local:myRectangle.RenderTransform> </local:myRectangle>
Canvas.SetLeft(myRectangleAnimate, Canvas.GetLeft(Selected)); Canvas.SetTop(myRectangleAnimate, Canvas.GetTop(Selected)); myRectangleAnimate.Opacity = 1.0; storyboardExpandContract.Begin();