--- title: "How to: Scale an Element" ms.date: "03/30/2017" helpviewer_keywords: - "scaling [WPF], elements" - "graphics [WPF], scaling elements" ms.assetid: 18158d94-bbe7-4f6a-814e-84d27fa748bf --- # How to: Scale an Element This example shows how to use a to scale an element. Use the and properties to resize the element by the factor you specify. For example, a value of 1.5 stretches the element to 150 percent of its original width. A value of 0.5 shrinks the height of an element by 50 percent. Use the and properties to specify the point that is the center of the scale operation. By default, a is centered at the point (0,0), which corresponds to the upper-left corner of the rectangle. This has the effect of moving the element and also of making it appear larger, because when you apply a , you change the coordinate space in which the object resides. The following example uses a to double the size of a 50-by-50 . The has a value of 0 (the default) for both and . ## Example [!code-xaml[transformsSample#21](~/samples/snippets/csharp/VS_Snippets_Wpf/transformsSample/CS/ScaleTransformExample.xaml#21)] Typically, you set and to the center of the object that is scaled: (/2, /2). The following example shows another that is doubled in size; however, this has a value of 25 for both and , which corresponds to the center of the rectangle. [!code-xaml[transformsSample#22](~/samples/snippets/csharp/VS_Snippets_Wpf/transformsSample/CS/ScaleTransformExample.xaml#22)] The following illustration shows the difference between the two operations. The dotted line shows the size and position of the rectangle before scaling. ![2x scales with different center points](./media/wcpsdk-graphicsmm-scalecenter.gif "wcpsdk_graphicsmm_scalecenter") Two ScaleTransform operations with identical ScaleX and ScaleY values but different centers For the complete sample, see [2D Transforms Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Graphics/2DTransforms). ## See also - - - [Transforms Overview](transforms-overview.md) - [How-to Topics](transformations-how-to-topics.md)