UIElement.RenderTransformOrigin UIElement.RenderTransformOrigin UIElement.RenderTransformOrigin UIElement.RenderTransformOrigin Property

Definición

Obtiene o establece el punto central de cualquier posible transformación de representación declarada por RenderTransform, relativa a los límites del elemento.Gets or sets the center point of any possible render transform declared by RenderTransform, relative to the bounds of the element. Es una propiedad de dependencia.This is a dependency property.

public:
 property System::Windows::Point RenderTransformOrigin { System::Windows::Point get(); void set(System::Windows::Point value); };
public System.Windows.Point RenderTransformOrigin { get; set; }
member this.RenderTransformOrigin : System.Windows.Point with get, set
Public Property RenderTransformOrigin As Point

Valor de propiedad

El valor que declara la transformación de representación.The value that declares the render transform. El valor predeterminado es un Point con las coordenadas (0,0).The default value is a Point with coordinates (0,0).

Ejemplos

El siguiente ejemplo se basa en el código de los elementos, se aplica un RenderTransformOriginy, a continuación, se aplica un RenderTransform.The following example builds up elements in code, applies a RenderTransformOrigin, and then applies a RenderTransform.

public RotateAboutCenterExample()
{
    this.WindowTitle = "Rotate About Center Example";
    NameScope.SetNameScope(this, new NameScope());
    StackPanel myStackPanel = new StackPanel();
    myStackPanel.Margin = new Thickness(50);

    Button myButton = new Button();
    myButton.Name = "myRenderTransformButton";
    this.RegisterName(myButton.Name,myButton);
    myButton.RenderTransformOrigin = new Point(0.5,0.5);
    myButton.HorizontalAlignment = HorizontalAlignment.Left;
    myButton.Content = "Hello World";


    RotateTransform myRotateTransform = new RotateTransform(0);
    myButton.RenderTransform = myRotateTransform;
    this.RegisterName("MyAnimatedTransform",myRotateTransform);

    myStackPanel.Children.Add(myButton);

    //
    // Creates an animation that accelerates through 40% of its duration and
    //      decelerates through the 60% of its duration.
    //
    DoubleAnimation myRotateAboutCenterAnimation = new DoubleAnimation();
    Storyboard.SetTargetName(myRotateAboutCenterAnimation,"MyAnimatedTransform");
    Storyboard.SetTargetProperty(myRotateAboutCenterAnimation,new PropertyPath(RotateTransform.AngleProperty));
    myRotateAboutCenterAnimation.From = 0.0;
    myRotateAboutCenterAnimation.To = 360;
    myRotateAboutCenterAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(1000));

    // Create a Storyboard to contain the animations and
    // add the animations to the Storyboard.
    Storyboard myStoryboard = new Storyboard();
    myStoryboard.Children.Add(myRotateAboutCenterAnimation);

    // Create an EventTrigger and a BeginStoryboard action to
    // start the storyboard.
    EventTrigger myEventTrigger = new EventTrigger();
    myEventTrigger.RoutedEvent = Button.ClickEvent;
    myEventTrigger.SourceName = myButton.Name;
    BeginStoryboard myBeginStoryboard = new BeginStoryboard();
    myBeginStoryboard.Storyboard = myStoryboard;
    myEventTrigger.Actions.Add(myBeginStoryboard);
    myStackPanel.Triggers.Add(myEventTrigger);

    this.Content = myStackPanel;
}
Public Sub New()
	Me.WindowTitle = "Rotate About Center Example"
	NameScope.SetNameScope(Me, New NameScope())
	Dim myStackPanel As New StackPanel()
	myStackPanel.Margin = New Thickness(50)

	Dim myButton As New Button()
	myButton.Name = "myRenderTransformButton"
	Me.RegisterName(myButton.Name,myButton)
	myButton.RenderTransformOrigin = New Point(0.5,0.5)
	myButton.HorizontalAlignment = HorizontalAlignment.Left
	myButton.Content = "Hello World"


	Dim myRotateTransform As New RotateTransform(0)
	myButton.RenderTransform = myRotateTransform
	Me.RegisterName("MyAnimatedTransform",myRotateTransform)

	myStackPanel.Children.Add(myButton)

	'
	' Creates an animation that accelerates through 40% of its duration and
	'      decelerates through the 60% of its duration.
	'
	Dim myRotateAboutCenterAnimation As New DoubleAnimation()
	Storyboard.SetTargetName(myRotateAboutCenterAnimation,"MyAnimatedTransform")
	Storyboard.SetTargetProperty(myRotateAboutCenterAnimation,New PropertyPath(RotateTransform.AngleProperty))
	myRotateAboutCenterAnimation.From = 0.0
	myRotateAboutCenterAnimation.To = 360
	myRotateAboutCenterAnimation.Duration = New Duration(TimeSpan.FromMilliseconds(1000))

	' Create a Storyboard to contain the animations and
	' add the animations to the Storyboard.
	Dim myStoryboard As New Storyboard()
	myStoryboard.Children.Add(myRotateAboutCenterAnimation)

	' Create an EventTrigger and a BeginStoryboard action to
	' start the storyboard.
	Dim myEventTrigger As New EventTrigger()
	myEventTrigger.RoutedEvent = Button.ClickEvent
	myEventTrigger.SourceName = myButton.Name
	Dim myBeginStoryboard As New BeginStoryboard()
	myBeginStoryboard.Storyboard = myStoryboard
	myEventTrigger.Actions.Add(myBeginStoryboard)
	myStackPanel.Triggers.Add(myEventTrigger)

	Me.Content = myStackPanel
End Sub

Comentarios

RenderTransformOrigin tiene un uso bastante no estándar de la Point estructura valor, en el que el Point no representa una ubicación absoluta en un sistema de coordenadas.RenderTransformOrigin has a somewhat nonstandard use of the Point structure value, in that the Point does not represent an absolute location in a coordinate system. En su lugar, los valores comprendidos entre 0 y 1 se interpretan como un factor para el intervalo del elemento actual en cada eje x, y.Instead, values between 0 and 1 are interpreted as a factor for the range of the current element in each x,y axis. Por ejemplo, (0,5.0,5) hará que la transformación de representación se centre en el elemento, o (1,1), debe colocar la transformación de representación en la parte inferior derecha del elemento.For example, (0.5,0.5) will cause the render transform to be centered on the element, or (1,1) would place the render transform at the bottom right corner of the element. NaN no es un valor aceptado.NaN is not an accepted value.

También se aceptan los valores superiores a 0 y 1 y más efectos de transformación poco convencionales dará como resultado.Values beyond 0 and 1 are also accepted, and will result in more unconventional transform effects. Por ejemplo, si establece RenderTransformOrigin (5,5) y, a continuación, aplicar un RotateTransform, será el punto de rotación bien fuera de los límites del propio elemento.For instance, if you set RenderTransformOrigin to be (5,5), and then apply a RotateTransform, the rotation point will be well outside the bounds of the element itself. La transformación girará el elemento en torno a en un círculo grande que se origina fuera de la parte inferior derecha.The transform will spin your element around in a big circle that originates beyond bottom right. El origen puede ser en algún lugar dentro de su elemento primario y posiblemente podría estar fuera del marco o vista.The origin might be somewhere inside its parent element and could possibly be possibly out of frame or view. Valores de punto negativos son similares, estos irá más allá de la parte superior izquierda de los límites.Negative point values are similar, these will go beyond the top left bounds.

Representar las transformaciones no afectan al diseño y se utiliza normalmente para animar o aplicar un efecto temporal a un elemento.Render transforms do not affect layout, and are typically used to animate or apply a temporary effect to an element.

Uso de atributos XAMLXAML Attribute Usage

<object RenderTransformOrigin="xOrigin, yOrigin"/>  

Uso de elementos de propiedad XAMLXAML Property Element Usage

<object>  
  <object.RenderTransformOrigin>  
    <Point X=" xOrigin " Y=" yOrigin "/>  
  </object.RenderTransformOrigin>  
</object>  

Valores XAMLXAML Values

xOriginxOrigin
El factor de origen horizontal.The horizontal origin factor. Esto se proporciona normalmente como un valor entre 0 y 1.This is typically given as a value between 0 and 1. Vea la sección Comentarios.See Remarks.

yOriginyOrigin
El factor de origen vertical.The vertical origin factor. Esto se proporciona normalmente como un valor entre 0 y 1.This is typically given as a value between 0 and 1. Vea la sección Comentarios.See Remarks.

Información sobre propiedades de dependenciaDependency Property Information

Campo de identificadorIdentifier field RenderTransformOriginProperty
Establecen las propiedades de metadatos en trueMetadata properties set to true NoneNone

Se aplica a

Consulte también: