Moving an element while rendering
TranslateTransform
is used to move an element from one position to another in the 2D interface. The X
and Y
properties are used to move an element towards the X and Y axes. In this recipe, we will learn how to apply this transforming to an element.
Getting ready
Open Visual Studio and create a project named CH08.TranslateTransformDemo
based on the WPF application template.
How to do it...
Follow these simple steps to move an image from a certain coordinate location specified by the X
and Y
properties:
- Before working on this, we need to add an image file to the project. From
Solution Explorer
, right-click on the project node and create a new folder. Name itImages
. - Now right-click on the
Images
folder and add an existing image from your system. Name itimage1.png
. - Open the
MainWindow.xaml
file and add two images inside theGrid
panel. Set the first one with a transparency of 30%. For the second image, add aTranslateTransform
to it at a (300
,80
) location specified...