请单击以进行评分并提供反馈
MSDN

  开启低带宽视图
此页面仅适用于
.NET Framework 3.0

同时提供下列产品的其他版本:
UIElement.RenderTransformOrigin 属性
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.

命名空间: System.Windows
程序集: PresentationCore(在 presentationcore.dll 中)
XML 命名空间:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

Visual Basic(声明)
Public Property RenderTransformOrigin As Point
Visual Basic (用法)
Dim instance As UIElement
Dim value As Point

value = instance.RenderTransformOrigin

instance.RenderTransformOrigin = value
C#
public Point RenderTransformOrigin { get; set; }
C++
public:
property Point RenderTransformOrigin {
    Point get ();
    void set (Point value);
}
J#
/** @property */
public Point get_RenderTransformOrigin ()

/** @property */
public void set_RenderTransformOrigin (Point value)
JScript
public function get RenderTransformOrigin () : Point

public function set RenderTransformOrigin (value : Point)
XAML 属性元素用法
<object>
  <object.RenderTransformOrigin>
    <Point X="xOrigin" Y="yOrigin"/>
  </object.RenderTransformOrigin>
</object>
XAML 属性用法
<object RenderTransformOrigin="xOrigin, yOrigin"/>
XAML 值
xOrigin

The horizontal origin factor. This is typically given as a value between 0 and 1. See Remarks.

yOrigin

The vertical origin factor. This is typically given as a value between 0 and 1. See Remarks.

属性值

The value that declares the render transform. The default value is a Point with coordinates (0,0).

Identifier field

RenderTransformOriginProperty

Metadata properties set to true

None

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. Instead, values between 0 and 1 are interpreted as a factor for the range of the current element in each x,y axis. 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 is not an accepted value.

Values beyond 0 and 1 are also accepted, and will result in more unconventional transform effects. 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.

The following example builds up elements in code, applies a RenderTransformOrigin, and then applies a RenderTransform.

C#
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;
}

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。

.NET Framework

受以下版本支持:3.0
社区内容   什么是社区内容?
添加新内容 RSS  批注
Processing
© 2009 Microsoft Corporation 版权所有。 保留所有权利  |  商标  |  隐私权声明
Page view tracker