mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-06 23:43:07 +02:00
* 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
25 lines
1.7 KiB
Markdown
25 lines
1.7 KiB
Markdown
---
|
|
title: "How to: Translate an Element"
|
|
ms.date: "03/30/2017"
|
|
helpviewer_keywords:
|
|
- "graphics [WPF], translations"
|
|
ms.assetid: 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-xaml[transformsSample#53](~/samples/snippets/csharp/VS_Snippets_Wpf/transformsSample/CS/TranslateTransformExample.xaml#53)]
|
|
|
|
For the complete sample, see [2D Transforms Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Graphics/2DTransforms).
|
|
|
|
## See also
|
|
|
|
- [Transforms Overview](transforms-overview.md)
|