O'Reilly logo

Windows Application Development Cookbook by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Animating the position of an element

You have already learned how to animate the color and size of an element, but what about its position? Could you create some animations regarding the location of an element? Of course! In this recipe, you will get to know how to do it.

Getting ready

To step through this recipe, you need only the automatically generated project.

How to do it...

To prepare the example that animates the square position, perform the following steps:

  1. Add a square to the page and define a storyboard for moving the square. Do this by modifying the content of the MainPage.xaml file, as follows:
            <Page (...)> 
                <Page.Resources> 
                    <Storyboard x:Name="RectangleMove"> <DoubleAnimation Storyboard.TargetName="RectangleMain" Storyboard.TargetProperty="(Canvas.Left)" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required