With WPF, how do I animate the position of a Window. I tried to simply animate the Left/Top properties, but it didn't work. Does anybody know how?
Thanks!
With WPF, how do I animate the position of a Window. I tried to simply animate the Left/Top properties, but it didn't work. Does anybody know how?
Thanks!
Just create a Storyboard for the window you're trying to animate.
Here's an example for a window named w1:
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard BeginTime="0" Duration="Forever">
<DoubleAnimation Storyboard.TargetName="w1" Storyboard.TargetProperty="(Window.Top)" From="0" To="300" AutoReverse="true" BeginTime="0:0:0" Duration="0:0:1" RepeatBehavior="Forever"/>
<DoubleAnimation Storyboard.TargetName="w1" Storyboard.TargetProperty="(Window.Left)" From="0" To="400" AutoReverse="true" BeginTime="0:0:0" Duration="0:0:2" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Window.Triggers>