共用方式為


CompositeTransform Class

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

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)

Syntax

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

The CompositeTransform type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows Phone CompositeTransform Initializes a new instance of the CompositeTransform class.

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows Phone CenterX Gets or sets the x-coordinate of the center point for all transforms specified by the CompositeTransform.
Public propertySupported by Silverlight for Windows Phone CenterY Gets or sets the y-coordinate of the center point for all transforms specified by the CompositeTransform.
Public propertySupported by Silverlight for Windows Phone Dispatcher Gets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public propertySupported by Silverlight for Windows Phone Inverse Gets the inverse of this transform, if it exists. (Inherited from Transform.)
Public propertySupported by Silverlight for Windows Phone Rotation Gets or sets the angle, in degrees, of clockwise rotation.
Public propertySupported by Silverlight for Windows Phone ScaleX Gets or sets the x-axis scale factor. You can use this property to stretch or shrink an object horizontally.
Public propertySupported by Silverlight for Windows Phone ScaleY Gets or sets the y-axis scale factor. You can use this property to stretch or shrink an object vertically.
Public propertySupported by Silverlight for Windows Phone 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.
Public propertySupported by Silverlight for Windows Phone 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.
Public propertySupported by Silverlight for Windows Phone TranslateX Gets or sets the distance to translate along the x-axis.
Public propertySupported by Silverlight for Windows Phone TranslateY Gets or sets the distance to translate (move) an object along the y-axis.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone CheckAccess Determines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone 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.)
Public methodSupported by Silverlight for Windows Phone GetAnimationBaseValue Returns any base value established for a Silverlight dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone ToString Returns a string that represents the current object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone Transform Transforms the specified point and returns the result. (Inherited from GeneralTransform.)
Public methodSupported by Silverlight for Windows Phone TransformBounds Transforms the specified bounding box and returns an axis-aligned bounding box that is exactly large enough to contain it. (Inherited from Transform.)
Public methodSupported by Silverlight for Windows Phone 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
Public fieldStatic memberSupported by Silverlight for Windows Phone CenterXProperty Identifies the CenterX dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone CenterYProperty Identifies the CenterY dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone RotationProperty Identifies the Rotation dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone ScaleXProperty Identifies the ScaleX dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone ScaleYProperty Identifies the ScaleY dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone SkewXProperty Identifies the SkewX dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone SkewYProperty Identifies the SkewY dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone TranslateXProperty Identifies the TranslateX dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone 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.

Run this sample

<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

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

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