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. 既定値は座標が (0, 0) の Point です。The default value is a Point with coordinates (0,0).

次の例では、コード内に要素をRenderTransformOrigin構築し、を適用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

注釈

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. たとえば、を (5, RenderTransformOrigin 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 属性の使用方法XAML 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 NoneNone

適用対象

こちらもご覧ください