Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-translate-an-element.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

1.7 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Translate an Element 03/30/2017
graphics [WPF], translations
461c8273-15df-42f6-8672-89ba22887cc0

How to: Translate an Element

This example shows how to translate (move) an element by using a xref:System.Windows.Media.TranslateTransform.

The xref:System.Windows.Media.TranslateTransform class is especially useful for moving elements inside panels that do not support absolute positioning. For example, by applying a xref:System.Windows.Media.TranslateTransform to the xref:System.Windows.UIElement.RenderTransform%2A property of an element, you can move an element within a xref:System.Windows.Controls.StackPanel or xref:System.Windows.Controls.DockPanel.

Use the xref:System.Windows.Media.TranslateTransform.X%2A property of the xref:System.Windows.Media.TranslateTransform to specify the amount, in pixels, to move the element along the x-axis. Use the xref:System.Windows.Media.TranslateTransform.Y%2A property to specify the amount, in pixels, to move the element along the y-axis. Finally, apply the xref:System.Windows.Media.TranslateTransform to the xref:System.Windows.UIElement.RenderTransform%2A property of the element.

The following example uses a xref:System.Windows.Media.TranslateTransform to move an element 50 pixels to the right and 50 pixels down.

Example

[!code-xamltransformsSample#53]

For the complete sample, see 2D Transforms Sample.

See also