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

定義

取得或設定 RenderTransform (相對於項目邊界) 宣告任何可能呈現轉換的中心點。Gets or sets the center point of any possible render transform declared by RenderTransform, relative to the bounds of the element. 這是相依性屬性。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

屬性值

宣告呈現轉換的值。The value that declares the render transform. 預設值是 Point 且座標為 (0,0)。The default value is a Point with coordinates (0,0).

範例

下列範例會建立在程式碼中的項目,適用於RenderTransformOrigin,然後再套用RenderTransformThe 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

備註

RenderTransformOrigin 有多少非標準方式使用Point結構中的值,Point不代表座標系統中的絕對位置。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. 相反地,介於 0 和 1 之間的值會解譯為目前的項目,在每個 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. 例如,(0.5,0.5) 會呈現轉換至元素上置中或 (1,1) 會將呈現轉換底端右下角的項目。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 不是可接受的值。NaN is not an accepted value.

0 和 1 以外的值也已被接受,並會導致更多的非傳統的轉換效果。Values beyond 0 and 1 are also accepted, and will result in more unconventional transform effects. 比方說,如果您設定RenderTransformOrigin(5,5),並接著套用RotateTransform,項目本身的範圍之外,也會旋轉的點。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. 轉換會旋轉您的項目源自右下角之外的大圓形。The transform will spin your element around in a big circle that originates beyond bottom right. 來源可能會在其父項目內的某處,並可能超出範圍或檢視表可能是。The origin might be somewhere inside its parent element and could possibly be possibly out of frame or view. 負數的點值類似,會產生超出左上方的界限。Negative point values are similar, these will go beyond the top left bounds.

呈現轉換不會影響版面配置,且通常用於動畫,或將暫存的效果套用至項目。Render transforms do not affect layout, and are typically used to animate or apply a temporary effect to an element.

XAML Attribute UsageXAML Attribute Usage

<object RenderTransformOrigin="xOrigin, yOrigin"/>  

XAML 屬性項目用法XAML Property Element Usage

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

XAML 值XAML Values

xOriginxOrigin
水平的原始比例。The horizontal origin factor. 這通常是指定為介於 0 和 1 之間的值。This is typically given as a value between 0 and 1. 請參閱<備註>。See Remarks.

yOriginyOrigin
垂直的原始比例。The vertical origin factor. 這通常是指定為介於 0 和 1 之間的值。This is typically given as a value between 0 and 1. 請參閱<備註>。See Remarks.

相依性屬性資訊Dependency Property Information

識別項欄位Identifier field RenderTransformOriginProperty
若要設定的中繼資料屬性 trueMetadata properties set to true None

適用於

另請參閱