Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Brush::RelativeTransform Property

Gets or sets the transformation that is applied to the brush using relative coordinates.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
public:
property Transform^ RelativeTransform {
	Transform^ get ();
	void set (Transform^ value);
}

Property Value

Type: System.Windows.Media::Transform
The transformation that is applied to the brush using relative coordinates. The default value is the Identity transformation.

Identifier field

RelativeTransformProperty

Metadata properties set to true

None

This property is especially useful when you want to rotate, scale, skew, or otherwise transform a brush about its center, but you don't know the size of the area painted with the brush, or you are using the same brush to paint different areas with different sizes.

For detailed information about this property, see the Brush Transformation Overview.

This example shows how to transform Brush objects by using their two transformation properties: RelativeTransform and Transform.

The following examples use a RotateTransform to rotate the content of an ImageBrush by 45 degrees.

The following illustration shows the ImageBrush without a RotateTransform, with the RotateTransform applied to the RelativeTransform property, and with the RotateTransform applied to the Transform property.

Brush RelativeTransform and Transform settings

The first example applies a RotateTransform to the RelativeTransform property of an ImageBrush. The CenterX and CenterY properties of a RotateTransform object are both set to 0.5, which is the relative coordinate of the center point of this content. As a result, the ImageBrush content rotates about its center.

No code example is currently available or this language may not be supported.
<Rectangle Width="175" Height="90" Stroke="Black">
  <Rectangle.Fill>
    <ImageBrush ImageSource="sampleImages\pinkcherries.jpg">
      <ImageBrush.RelativeTransform>
        <RotateTransform CenterX="0.5" CenterY="0.5" Angle="45" />
      </ImageBrush.RelativeTransform>
    </ImageBrush>
  </Rectangle.Fill>
</Rectangle>

The second example also applies a RotateTransform to an ImageBrush; however, this example uses the Transform property instead of the RelativeTransform property.

To rotate the brush about its center, the example sets the CenterX and CenterY properties of the RotateTransform object to absolute coordinates. Because the brush paints a rectangle that is 175 by 90 pixels, the center point of the rectangle is (87.5, 45).

No code example is currently available or this language may not be supported.
<Rectangle Width="175" Height="90" Stroke="Black">
  <Rectangle.Fill>
    <ImageBrush ImageSource="sampleImages\pinkcherries.jpg">
      <ImageBrush.Transform>
        <RotateTransform CenterX="87.5" CenterY="45" Angle="45" />
      </ImageBrush.Transform>
    </ImageBrush>
  </Rectangle.Fill>
</Rectangle>

For a description of how the RelativeTransform and Transform properties work, see the Brush Transformation Overview.

For the complete sample, see Brushes Sample. For more information about brushes, see Painting with Solid Colors and Gradients Overview.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.