CompositeTransform Class
TOC
Collapse the table of content
Expand the table of content

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.

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

public sealed class CompositeTransform : Transform
<CompositeTransform .../>

The CompositeTransform type exposes the following members.

  NameDescription
Public methodCompositeTransformInitializes a new instance of the CompositeTransform class.
Top

  NameDescription
Public propertyCenterXGets or sets the x-coordinate of the center point for all transforms specified by the CompositeTransform.
Public propertyCenterYGets or sets the y-coordinate of the center point for all transforms specified by the CompositeTransform.
Public propertyDispatcherGets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public propertyInverseGets the inverse of this transform, if it exists. (Inherited from Transform.)
Public propertyRotationGets or sets the angle, in degrees, of clockwise rotation.
Public propertyScaleXGets or sets the x-axis scale factor. You can use this property to stretch or shrink an object horizontally.
Public propertyScaleYGets or sets the y-axis scale factor. You can use this property to stretch or shrink an object vertically.
Public propertySkewXGets 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.
Public propertySkewYGets 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.
Public propertyTranslateXGets or sets the distance to translate along the x-axis.
Public propertyTranslateYGets or sets the distance to translate (move) an object along the y-axis.
Top

  NameDescription
Public methodCheckAccessDetermines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodClearValueClears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetAnimationBaseValueReturns any base value established for a Windows Phone dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValueReturns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodReadLocalValueReturns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSetValueSets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTransformTransforms the specified point and returns the result. (Inherited from GeneralTransform.)
Public methodTransformBoundsTransforms the specified bounding box and returns an axis-aligned bounding box that is exactly large enough to contain it. (Inherited from Transform.)
Public methodTryTransformAttempts to transform the specified point and returns a value that indicates whether the transformation was successful. (Inherited from Transform.)
Top

  NameDescription
Public fieldStatic memberCenterXPropertyIdentifies the CenterX dependency property.
Public fieldStatic memberCenterYPropertyIdentifies the CenterY dependency property.
Public fieldStatic memberRotationPropertyIdentifies the Rotation dependency property.
Public fieldStatic memberScaleXPropertyIdentifies the ScaleX dependency property.
Public fieldStatic memberScaleYPropertyIdentifies the ScaleY dependency property.
Public fieldStatic memberSkewXPropertyIdentifies the SkewX dependency property.
Public fieldStatic memberSkewYPropertyIdentifies the SkewY dependency property.
Public fieldStatic memberTranslateXPropertyIdentifies the TranslateX dependency property.
Public fieldStatic memberTranslateYPropertyIdentifies the TranslateY dependency property.
Top

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.

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>


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

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

Show:
© 2017 Microsoft