Windows Dev Center

ScaleTransform class

Scales an object in the two-dimensional x-y coordinate system.

Inheritance

Object
  DependencyObject
    GeneralTransform
      Transform
        ScaleTransform

Syntax


public sealed class ScaleTransform : Transform


<ScaleTransform .../>

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The ScaleTransform class has these types of members:

Constructors

The ScaleTransform class has these constructors.

ConstructorDescription
ScaleTransform Initializes a new instance of the ScaleTransform class.

 

Methods

The ScaleTransform class has these methods. It also inherits methods from the Object class.

MethodDescription
ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject)
GetAnimationBaseValue Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject)
GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject)
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)
TransformBounds Transforms the specified bounding box and returns an axis-aligned bounding box that is exactly large enough to contain it. (Inherited from GeneralTransform)
TransformBoundsCore Provides the means to override the TransformBounds behavior in a derived transform class. (Inherited from GeneralTransform)
TransformPoint Uses this transformation object's logic to transform the specified point, and returns the result. (Inherited from GeneralTransform)
TryTransform Attempts to transform the specified point and returns a value that indicates whether the transformation was successful. (Inherited from GeneralTransform)
TryTransformCore Provides the means to override the TryTransform behavior in a derived transform class. (Inherited from GeneralTransform)

 

Properties

The ScaleTransform class has these properties.

PropertyAccess typeDescription

CenterX

Read/writeGets or sets the x-coordinate of the center point of this ScaleTransform.

CenterXProperty

Read-onlyIdentifies the CenterX dependency property.

CenterY

Read/writeGets or sets the y-coordinate of the center point of this ScaleTransform.

CenterYProperty

Read-onlyIdentifies the CenterY dependency property.

Dispatcher

Read-onlyGets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread. (Inherited from DependencyObject)

Inverse

Read-onlyGets the inverse transformation of this GeneralTransform, if possible. (Inherited from GeneralTransform)

InverseCore

Read-onlyImplements the behavior for return value of Inverse in a derived or custom GeneralTransform. (Inherited from GeneralTransform)

ScaleX

Read/writeGets or sets the x-axis scale factor.

ScaleXProperty

Read-onlyIdentifies the ScaleX dependency property.

ScaleY

Read/writeGets or sets the y-axis scale factor.

ScaleYProperty

Read-onlyIdentifies the ScaleY dependency property.

 

Examples

This XAML example uses a ScaleTransform to scale text from its original size.


<StackPanel>
    <TextBlock FontFamily="Verdana"
               FontSize="32"
               FontWeight="Bold" 
               Foreground="SteelBlue"
               Text="Scaled Text" />

    <!-- Scale the text width using a ScaleTransform. -->
    <TextBlock FontFamily="Verdana"
               FontSize="32"
               FontWeight="Bold"
               Foreground="SteelBlue"
               Text="Scaled Text">
        <TextBlock.RenderTransform>
            <ScaleTransform ScaleX="1.5" ScaleY="1.0" />
        </TextBlock.RenderTransform>
    </TextBlock>

    <!-- Scale the text height using a ScaleTransform. -->
    <TextBlock FontFamily="Verdana"
               FontSize="32"
               FontWeight="Bold" 
               Foreground="SteelBlue"
               Text="Scaled Text">
        <TextBlock.RenderTransform>
            <ScaleTransform ScaleX="1.0" ScaleY="1.5" />
        </TextBlock.RenderTransform>
    </TextBlock>
</StackPanel>


Transform objects can be accessed and manipulated by using code. One way to do this is to name the Transform and then access it by using code. The next example shows how to increase the ScaleX and ScaleY property values of a ScaleTransform applied to a Rectangle every time that Rectangle is clicked.


<StackPanel>
  <Rectangle PointerPressed="HandlePointerPressed"
    Width="50" Height="50" Fill="RoyalBlue">
    <Rectangle.RenderTransform>

      <!-- If you give the transform a name you can 
        access it easily from code. -->
      <ScaleTransform x:Name="myScaleTransform" />
    </Rectangle.RenderTransform>
  </Rectangle>
</StackPanel>



private void HandlePointerPressed(object sender, PointerRoutedEventArgs e)
{
    // Increase ScaleX and ScaleY by 25%.
    myScaleTransform.ScaleX = myScaleTransform.ScaleX * 1.25;
    myScaleTransform.ScaleY = myScaleTransform.ScaleY * 1.25;
}


Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Xaml.Media
Windows::UI::Xaml::Media [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Media
Windows::UI::Xaml::Media [C++]

Metadata

Windows.winmd

See also

Object
Transform
XAML two-dimensional transforms sample

 

 

Show:
© 2015 Microsoft