--- title: "How to: Specify the Origin of a Transform by Using Relative Values" ms.date: "03/30/2017" helpviewer_keywords: - "origins of Transforms [WPF]" - "Transforms [WPF], origins of" - "graphics [WPF], origins of Transforms" ms.assetid: f4dbc29d-93c7-41cd-96d8-5cfd8624b470 --- # How to: Specify the Origin of a Transform by Using Relative Values This example shows how to use relative values to specify the origin of a that is applied to a . When you rotate, scale, or skew a by using the property, the default setting applies the transform to the upper-left corner of the element. If you want to rotate, scale, or skew from the center of the element, you can compensate by setting the center of the transform to the center of the element. However, that solution requires that you know the size of the element. An easier way of applying a transform to the center of an element is to set its property to (0.5, 0.5), instead of setting a center value on the transform itself. ## Example The following example uses a to rotate a 45 degrees clockwise. Because the example does not specify a center, the button rotates about the point (0, 0), which is its upper-left corner. The is applied to the property. The following illustration shows the transformation result for the example that follows. ![A button transformed using RenderTransform](./media/graphicsmm-rendertransformwithdefaultcenter.png "graphicsmm_RenderTransformWithDefaultCenter") A 45 degree clockwise rotation by using the RenderTransform property [!code-xaml[Transforms_snip#GraphicsMMRotateButtonExample1](~/samples/snippets/csharp/VS_Snippets_Wpf/Transforms_snip/CS/ButtonRotateTransformExample.xaml#graphicsmmrotatebuttonexample1)] The following example also uses a to rotate a 45 degrees clockwise; however, this example sets the of the button to (0.5, 0.5). As a result, the rotation is applied to the center of the button instead of to the upper-left corner. The following illustration shows the transformation result for the example that follows. ![A button transformed about its center](./media/graphicsmm-rendertransformrelativecenter.png "graphicsmm_RenderTransformRelativeCenter") A 45 degree rotation by using the RenderTransform property with a RenderTransformOrigin of (0.5, 0.5) [!code-xaml[Transforms_snip#GraphicsMMRotateButtonExample2](~/samples/snippets/csharp/VS_Snippets_Wpf/Transforms_snip/CS/ButtonRotateTransformExample.xaml#graphicsmmrotatebuttonexample2)] For more information about transforming objects, see the [Transforms Overview](transforms-overview.md). ## See also - - [Transforms Overview](transforms-overview.md) - [How-to Topics](transformations-how-to-topics.md)