TranslateTransform TranslateTransform TranslateTransform TranslateTransform Class

Definition

Translates (moves) an object in the two-dimensional x-y coordinate system.

public : sealed class TranslateTransform : Transform, ITranslateTransform
public sealed class TranslateTransform : Transform, ITranslateTransform
Public NotInheritable Class TranslateTransform Inherits Transform Implements ITranslateTransform
var translateTransform = new translateTransform();
<TranslateTransform .../>
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

This example uses a TranslateTransform to offset text. In this example, a slightly offset copy of text below the primary text creates a shadow effect.

<Canvas>

    <!-- Offset the text using a TranslateTransform. -->
    <TextBlock FontFamily="Verdana"
               FontSize="32"
               FontWeight="Bold" 
               Foreground="Black"
               Text="Translated Text">
        <TextBlock.RenderTransform>
            <TranslateTransform X="2" Y="2" />
        </TextBlock.RenderTransform>
    </TextBlock>

    <TextBlock FontFamily="Verdana"
               FontSize="32"
               FontWeight="Bold" 
               Foreground="Coral"
               Text="Translated Text"/>

</Canvas>
<Canvas Width="200" Height="200">
    <Rectangle PointerPressed="Rectangle_PointerPressed" 
               Width="50" Height="50" 
               Fill="RoyalBlue">
        <Rectangle.RenderTransform>
            <!-- If you give the transform a name 
                 you can access it easily from code. -->
            <TranslateTransform x:Name="myTranslateTransform" />
        </Rectangle.RenderTransform>
    </Rectangle>
</Canvas>
private void Rectangle_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
    // Increase the X and Y properties.
    myTranslateTransform.X = myTranslateTransform.X + 15;
    myTranslateTransform.Y = myTranslateTransform.Y + 15;
}

Constructors

TranslateTransform() TranslateTransform() TranslateTransform() TranslateTransform()

Initializes a new instance of the TranslateTransform class.

public : TranslateTransform()
public TranslateTransform()
Public Sub New()
var translateTransform = new translateTransform();

Properties

X X X X

Gets or sets the distance to translate along the x-axis.

public : double X { get; set; }
public double X { get; set; }
Public ReadWrite Property X As double
var double = translateTransform.x;
translateTransform.x = double;
<TranslateTransform X="double"/>
Value
double double double double

The distance to translate (move) an object along the x-axis, in pixels. This property is read/write. The default is 0.

XProperty XProperty XProperty XProperty

Identifies the X dependency property.

public : static DependencyProperty XProperty { get; }
public static DependencyProperty XProperty { get; }
Public Static ReadOnly Property XProperty As DependencyProperty
var dependencyProperty = Windows.UI.Xaml.Media.TranslateTransform.xProperty;
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier for the X dependency property.

Y Y Y Y

Gets or sets the distance to translate (move) an object along the y-axis.

public : double Y { get; set; }
public double Y { get; set; }
Public ReadWrite Property Y As double
var double = translateTransform.y;
translateTransform.y = double;
<TranslateTransform Y="double"/>
Value
double double double double

The distance to translate (move) an object along the y-axis, in pixels. The default is 0.

YProperty YProperty YProperty YProperty

Identifies the Y dependency property.

public : static DependencyProperty YProperty { get; }
public static DependencyProperty YProperty { get; }
Public Static ReadOnly Property YProperty As DependencyProperty
var dependencyProperty = Windows.UI.Xaml.Media.TranslateTransform.yProperty;
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier for the Y dependency property.

Dispatcher Dispatcher Dispatcher Dispatcher

Inherited from DependencyObject

Inverse Inverse Inverse Inverse

Inherited from GeneralTransform

InverseCore InverseCore InverseCore InverseCore

Inherited from GeneralTransform

Methods

ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Inherited from DependencyObject

GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Inherited from DependencyObject

GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Inherited from DependencyObject

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Inherited from DependencyObject

RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Inherited from DependencyObject

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Inherited from DependencyObject

TransformBounds(Rect) TransformBounds(Rect) TransformBounds(Rect) TransformBounds(Rect)

Inherited from GeneralTransform

TransformBoundsCore(Rect) TransformBoundsCore(Rect) TransformBoundsCore(Rect) TransformBoundsCore(Rect)

Inherited from GeneralTransform

TransformPoint(Point) TransformPoint(Point) TransformPoint(Point) TransformPoint(Point)

Inherited from GeneralTransform

UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Inherited from DependencyObject

See Also