Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 3.0
Class Library
 X Property
Collapse All/Expand All Collapse All
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
TranslateTransform.X Property
Gets or sets the distance to translate along the x-axis. This is a dependency property.

Namespace: System.Windows.Media
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

Visual Basic (Declaration)
Public Property X As Double
Visual Basic (Usage)
Dim instance As TranslateTransform
Dim value As Double

value = instance.X

instance.X = value
C#
public double X { get; set; }
C++
public:
property double X {
    double get ();
    void set (double value);
}
J#
/** @property */
public double get_X ()

/** @property */
public void set_X (double value)
JScript
public function get X () : double

public function set X (value : double)
XAML Attribute Usage
<object X="double" .../>

Property Value

The distance to translate (move) an object along the x-axis. The default value is 0.

Identifier field

XProperty

Metadata properties set to true

None

Negative values move an object to the left; positive values move an object to the right.

This example shows how to translate (move) an element by using a TranslateTransform.

The TranslateTransform class is especially useful for moving elements inside panels that do not support absolute positioning. For example, by applying a TranslateTransform to the RenderTransform property of an element, you can move an element within a StackPanel or DockPanel.

Use the X property of the TranslateTransform to specify the amount, in pixels, to move the element along the x-axis. Use the Y property to specify the amount, in pixels, to move the element along the y-axis. Finally, apply the TranslateTransform to the RenderTransform property of the element.

The following example uses a TranslateTransform to move an element 50 pixels to the right and 50 pixels down.

XAML
<Rectangle Height="50" Width="50" 
  Fill="#CCCCCCFF" Stroke="Blue" StrokeThickness="2"
  Canvas.Left="100" Canvas.Top="100">
  <Rectangle.RenderTransform>
    <TranslateTransform X="50" Y="50" />
  </Rectangle.RenderTransform>
</Rectangle>

For the complete sample, see 2-D Transforms Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker