Share via


RelativeTransform Property

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

XAML
<object RelativeTransform="Transform" .../>
Scripting
value = object.RelativeTransform
object.RelativeTransform = value

Property Value

Transform

The transformation that is applied to the brush using relative coordinates.

This property is read/write. The default value is null.

Remarks

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.

Examples

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.

XAML
<Canvas
  xmlns="https://schemas.microsoft.com/client/2007"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
  Width="175" Height="90">
  <Canvas.Background>
    <ImageBrush ImageSource="sampleImages/pinkcherries.jpg" >
      <ImageBrush.RelativeTransform>
        <RotateTransform CenterX="0.5" CenterY="0.5" Angle="45" />
      </ImageBrush.RelativeTransform>
    </ImageBrush>
  </Canvas.Background>
</Canvas>

The following illustrations shows the ImageBrush with and without a RotateTransform.

No Transform

No Transform

RotateTransform

RotateTransform

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 a 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).

XAML
<Canvas
  xmlns="https://schemas.microsoft.com/client/2007"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
  Width="175" Height="90">
  <Canvas.Background>
    <ImageBrush ImageSource="sampleImages/pinkcherries.jpg" >
      <ImageBrush.Transform>
        <RotateTransform CenterX="87.5" CenterY="45" Angle="45" />
      </ImageBrush.Transform>
    </ImageBrush>
  </Canvas.Background>
</Canvas>

Applies To

ImageBrush, LinearGradientBrush, RadialGradientBrush, SolidColorBrush, VideoBrush

See Also

Silverlight Transforms Overview
Silverlight Brushes Overview
Transform