EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

TranslateTransform class

Applies to Windows and Windows Phone

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

Inheritance

Object
  DependencyObject
    GeneralTransform
      Transform
        TranslateTransform

Syntax


public sealed class TranslateTransform : Transform


<TranslateTransform .../>

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The TranslateTransform class has these types of members:

Constructors

The TranslateTransform class has these constructors.

ConstructorDescription
TranslateTransform Initializes a new instance of the TranslateTransform class.

 

Methods

The TranslateTransform class has these methods. It also inherits methods from the Object class.

MethodDescription
ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject)
GetAnimationBaseValue Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject)
GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject)
ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject)
SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject)
TransformBounds Transforms the specified bounding box and returns an axis-aligned bounding box that is exactly large enough to contain it. (Inherited from GeneralTransform)
TransformBoundsCore Provides the means to override the TransformBounds behavior in a derived transform class. (Inherited from GeneralTransform)
TransformPoint Uses this transformation object's logic to transform the specified point, and returns the result. (Inherited from GeneralTransform)
TryTransform Attempts to transform the specified point and returns a value that indicates whether the transformation was successful. (Inherited from GeneralTransform)
TryTransformCore Provides the means to override the TryTransform behavior in a derived transform class. (Inherited from GeneralTransform)

 

Properties

The TranslateTransform class has these properties.

PropertyAccess typeDescription

Dispatcher

Read-onlyGets the CoreDispatcher that this object is associated with. (Inherited from DependencyObject)

Inverse

Read-onlyGets the inverse transformation of this GeneralTransform, if possible. (Inherited from GeneralTransform)

InverseCore

Read-onlyImplements the behavior for return value of Inverse in a derived or custom GeneralTransform. (Inherited from GeneralTransform)

X

Read/writeGets or sets the distance to translate along the x-axis.

XProperty

Read-onlyIdentifies the X dependency property.

Y

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

YProperty

Read-onlyIdentifies the Y dependency property.

 

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>


The next example shows how to increase the X and Y property values of a TranslateTransform applied to a Rectangle every time the Rectangle is clicked.


<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;
}


Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Media
Windows::UI::Xaml::Media [C++]

Metadata

Windows.winmd

See also

XAML two-dimensional transforms sample
Transform

 

 

Mostrar:
© 2014 Microsoft