UIElement.RenderTransformOrigin Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define o ponto central de qualquer possível transformação de renderização declarada por RenderTransform, relativamente aos limites do elemento. Isto é uma propriedade de dependência.
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 Propriedade
O valor que declara a transformação de renderização. O valor padrão é a Point com coordenadas (0,0).
Exemplos
O exemplo seguinte constrói elementos no código, aplica um RenderTransformOrigin, e depois aplica um 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
Observações
RenderTransformOrigin tem um uso algo não padrão do Point valor estrutural, pois o Point não representa uma localização absoluta num sistema de coordenadas. Em vez disso, valores entre 0 e 1 são interpretados como um fator para o intervalo do elemento atual em cada eixo x,y. Por exemplo, (0.5,0.5) fará com que a transformação de renderização fique centrada no elemento, ou (1,1) colocará a transformação no canto inferior direito do elemento. NaN não é um valor aceite.
Valores superiores a 0 e 1 também são aceites, o que resultará em efeitos de transformação mais pouco convencionais. Por exemplo, se definir RenderTransformOrigin para (5,5), e depois aplicar um RotateTransform, o ponto de rotação ficará bem fora dos limites do próprio elemento. A transformação vai rodar o teu elemento num grande círculo que se origina para além do canto inferior direito. A origem pode estar algures dentro do seu elemento principal e pode estar fora do enquadramento ou da vista. Valores negativos em pontos são semelhantes, estes irão para além dos limites superiores esquerdos.
As transformações de renderização não afetam o layout e são tipicamente usadas para animar ou aplicar um efeito temporário a um elemento.
Uso de atributos XAML
<object RenderTransformOrigin="xOrigin, yOrigin"/>
Uso do elemento de propriedade XAML
<object>
<object.RenderTransformOrigin>
<Point X=" xOrigin " Y=" yOrigin "/>
</object.RenderTransformOrigin>
</object>
Valores XAML
xOrigem O fator de origem horizontal. Isto é tipicamente dado como um valor entre 0 e 1. Ver Observações.
yOrigem O fator de origem vertical. Isto é tipicamente dado como um valor entre 0 e 1. Ver Observações.
Informação de Propriedade de Dependência
| Número | valor |
|---|---|
| Campo identificador | RenderTransformOriginProperty |
Propriedades dos metadados definidas como true |
None |