<Canvas Name="canvas1">

<Ellipse Width="48" Height="48" Fill="Blue" Name="ball" Canvas.Left="0" Canvas.Top="0"/>

<Canvas.Triggers>

<EventTrigger RoutedEvent="Canvas.SizeChanged">

<!--Canvas Size 바뀔때(폼사이즈 변경시 canvas사이즈도 변경됨)-->

<BeginStoryboard>

<Storyboard><!--움직이는 영역의 To값을 canvas 크기로 바운딩-->

<DoubleAnimation<!--Left 변경-->

Storyboard.TargetName="ball"

Storyboard.TargetProperty="(Canvas.Left)"

<!--Ball 움직이는 마지막 Left값을 Canvas 현재Width값으로 바인딩-->

From="0" To="{Binding ElementName=canvas1, Path=ActualWidth}"

Duration="0:0:2"

AutoReverse="True"

RepeatBehavior="Forever"/>

 

<DoubleAnimation<!--Right 변경-->

Storyboard.TargetName="ball"

Storyboard.TargetProperty="(Canvas.Top)"

<!--Ball 움직이는 마지막 Top값을 Canvas 현재Height값으로 바인딩-->

From="0" To="{Binding ElementName=canvas1, Path=ActualHeight}"

Duration="0:0:2"

AutoReverse="True"

RepeatBehavior="Forever"/>

</Storyboard>

</BeginStoryboard>

</EventTrigger>

</Canvas.Triggers></Canvas>


by 피요히코~ 2009. 2. 25. 13:04