TranslateTransform TranslateTransform TranslateTransform Class

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

Syntax

Declaration

public sealed class TranslateTransformpublic sealed class TranslateTransformPublic NotInheritable Class TranslateTransform
<TranslateTransform .../>

Inheritance Hierarchy

Inherited Members

, , , , , , , , ,
Windows.UI.Xaml.Media.GeneralTransform.TryTransform(Windows.Foundation.Point,Windows.Foundation.Point)
Windows.UI.Xaml.Media.GeneralTransform.TryTransform(Windows.Foundation.Point,Windows.Foundation.Point)
Windows.UI.Xaml.Media.GeneralTransform.TryTransform(Windows.Foundation.Point,Windows.Foundation.Point)
, ,

Remarks

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 summary

Initializes a new instance of the TranslateTransform class.

Properties summary

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

Identifies the X dependency property.

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

Identifies the Y dependency property.

Constructors

  • TranslateTransform()
    TranslateTransform()
    TranslateTransform()
    TranslateTransform()

    Initializes a new instance of the TranslateTransform class.

    public TranslateTransform()public TranslateTransform()Public Function TranslateTransform() As

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
    <TranslateTransform X="double"/>
    

    Property Value

    • 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

    Property Value

  • 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
    <TranslateTransform Y="double"/>
    

    Property Value

    • 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

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Media.dll