Поделиться через


TransformGroup

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents a composite Transform composed of other Transform objects.

<TransformGroup>
  oneOrMoreTransforms
</TransformGroup>

XAML Values

Value

Description

oneOrMoreTransforms

One or more of the following object elements that derive from Transform: RotateTransform, ScaleTransform, SkewTransform, TranslateTransform, MatrixTransform, or TransformGroup. Object elements defined here become members of the Children collection when scripting accesses the Children property at run time.

Managed Equivalent

TransformGroup

Remarks

Use a TransformGroup when you want to apply multiple Transform objects to a single property.

In a composite transformation, the order of individual transformations is important. For example, if you first rotate, then scale, and then translate, you get a different result than if you first translate, then rotate, and then scale. One reason order is significant is that transformations such as rotation and scaling are done with respect to the origin of the coordinate system. Scaling an object that is centered at the origin produces a different result than scaling an object that has been moved away from the origin. Similarly, rotating an object that is centered at the origin produces a different result than rotating an object that has been moved away from the origin.

In XAML, TransformGroup uses Children as its content property and supports implicit collection usage. Therefore, to declare transforms that will be in a TransformGroup in XAML, you declare one or more transforms as object elements, placing them in order as the child elements of the TransformGroup. Nesting TransformGroup objects is permitted.

Example

The following example shows the markup for using a TransformGroup to fill the RenderTransform property.

<Canvas
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
  Width="200" Height="200">
  <TextBlock FontSize="28" 
    Canvas.Left="100" Canvas.Top="100"
    Width="50" Height="50"
    Text="Hello">
    <TextBlock.RenderTransform>
      <TransformGroup>
        <RotateTransform Angle="45" />
        <SkewTransform CenterX="0" CenterY="0" AngleX="60"/>
      </TransformGroup>
    </TextBlock.RenderTransform>
  </TextBlock>
</Canvas>