CompositeTransform Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

This class lets you apply multiple different transforms to an object.

Inheritance Hierarchy

System..::.Object
  System.Windows..::.DependencyObject
    System.Windows.Media..::.GeneralTransform
      System.Windows.Media..::.Transform
        System.Windows.Media..::.CompositeTransform

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

Syntax

Public NotInheritable Class CompositeTransform _
    Inherits Transform
public sealed class CompositeTransform : Transform
<CompositeTransform .../>

The CompositeTransform type exposes the following members.

Constructors

  Name Description
CompositeTransform Initializes a new instance of the CompositeTransform class.

Top

Properties

  Name Description
CenterX Gets or sets the x-coordinate of the center point for all transforms specified by the CompositeTransform.
CenterY Gets or sets the y-coordinate of the center point for all transforms specified by the CompositeTransform.
Dispatcher Gets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Inverse Gets the inverse of this transform, if it exists. (Inherited from Transform.)
Rotation Gets or sets the angle, in degrees, of clockwise rotation.
ScaleX Gets or sets the x-axis scale factor. You can use this property to stretch or shrink an object horizontally.
ScaleY Gets or sets the y-axis scale factor. You can use this property to stretch or shrink an object vertically.
SkewX Gets or sets the x-axis skew angle, which is measured in degrees counterclockwise from the y-axis. A skew transform can be useful for creating the illusion of three-dimensional depth in a two-dimensional object.
SkewY Gets or sets the y-axis skew angle, which is measured in degrees counterclockwise from the x-axis. A skew transform can be useful for creating the illusion of three-dimensional depth in a two-dimensional object.
TranslateX Gets or sets the distance to translate along the x-axis.
TranslateY Gets or sets the distance to translate (move) an object along the y-axis.

Top

Methods

  Name Description
CheckAccess Determines whether the calling thread has access to this object. (Inherited from DependencyObject.)
ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject.)
Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
GetAnimationBaseValue Returns any base value established for a Windows Phone dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
GetType Gets the Type of the current instance. (Inherited from Object.)
GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
ToString Returns a string that represents the current object. (Inherited from Object.)
Transform Transforms the specified point and returns the result. (Inherited from GeneralTransform.)
TransformBounds Transforms the specified bounding box and returns an axis-aligned bounding box that is exactly large enough to contain it. (Inherited from Transform.)
TryTransform Attempts to transform the specified point and returns a value that indicates whether the transformation was successful. (Inherited from Transform.)

Top

Fields

  Name Description
CenterXProperty Identifies the CenterX dependency property.
CenterYProperty Identifies the CenterY dependency property.
RotationProperty Identifies the Rotation dependency property.
ScaleXProperty Identifies the ScaleX dependency property.
ScaleYProperty Identifies the ScaleY dependency property.
SkewXProperty Identifies the SkewX dependency property.
SkewYProperty Identifies the SkewY dependency property.
TranslateXProperty Identifies the TranslateX dependency property.
TranslateYProperty Identifies the TranslateY dependency property.

Top

Remarks

Instead of applying transforms to an object by using individual transform objects in a TransformGroup (for example, ScaleTransform or SkewTransform), you can use a single instance of the CompositeTransform object to apply all these basic transforms (see the example below). This enables you to make your XAML code more concise. In addition, CompositeTransform applies multiple transforms in the following recommended order:

  1. Scale

  2. Skew

  3. Rotate

  4. Translate

If, for whatever reason, you want to apply multiple transforms to an object in a different order than is recommended here, you can use the TransformGroup to do this. The TransformGroup is also useful if you want to specify different center points for the various transforms you apply. For example, the CenterX and CenterY properties on the CompositeTransform is applied to all transforms of the CompositeTransform while you can specify different center points for ScaleTransform, SkewTransform, and RotateTransform within a TransformGroup.

Examples

The following example shows how to apply the same transforms to an object by using either a TransformGroup or a TransformGroup.

<StackPanel Margin="50">
    <Canvas Background="Black" Width="200" Height="200">
        <Rectangle Height="100" Width="100" Fill="Red">
          <Rectangle.RenderTransform>

            <!-- This one line of markup is the equivalent of the entire
                 TransformGroup block in the other Canvas below. -->
            <CompositeTransform SkewX="30" Rotation="45" ScaleX="0.8" ScaleY="0.8" />
        </Rectangle.RenderTransform>
    </Rectangle>
    </Canvas>

    <Canvas Margin="10" Background="Black" Width="200" Height="200">
        <Rectangle Height="100" Width="100" Fill="Red">
            <Rectangle.RenderTransform>
                <TransformGroup>

                    <!-- Note that you have to apply these transforms in 
                         a specific order to get the same effect as the
                         CompositeTransform. -->
                    <ScaleTransform ScaleX="0.8" ScaleY="0.8" />
                    <SkewTransform AngleX="30" />
                    <RotateTransform Angle="45" /> 
                </TransformGroup>
            </Rectangle.RenderTransform>
        </Rectangle>
    </Canvas>
</StackPanel>

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Windows.Media Namespace