--- title: "How to: Transform a Brush" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "brushes [WPF], rotating contents" - "brushes [WPF], Transform property" - "rotating contents of brushes [WPF]" ms.assetid: ebada2f9-f01f-4863-9ea2-c2e4e51610f1 --- # How to: Transform a Brush This example shows how to transform objects by using their two transformation properties: and . The following examples use a to rotate the content of an by 45 degrees. The following illustration shows the without a , with the applied to the property, and with the applied to the property. ![Brush RelativeTransform and Transform settings](./media/wcpsdk-graphicsmm-transformandrelativetransform.png "wcpsdk_graphicsmm_transformandrelativetransform") ## Example The first example applies a to the property of an . The and properties of a object are both set to 0.5, which is the relative coordinate of the center point of this content. As a result, the content rotates about its center. [!code-csharp[BrushesIntroduction_snip#ImageBrushRelativeTransformExample](~/samples/snippets/csharp/VS_Snippets_Wpf/BrushesIntroduction_snip/CSharp/BrushTransformExample.cs#imagebrushrelativetransformexample)] [!code-vb[BrushesIntroduction_snip#ImageBrushRelativeTransformExample](~/samples/snippets/visualbasic/VS_Snippets_Wpf/BrushesIntroduction_snip/visualbasic/brushtransformexample.vb#imagebrushrelativetransformexample)] [!code-xaml[BrushesIntroduction_snip#ImageBrushRelativeTransformExample](~/samples/snippets/xaml/VS_Snippets_Wpf/BrushesIntroduction_snip/XAML/BrushTransformExample.xaml#imagebrushrelativetransformexample)] The second example also applies a to an ; however, this example uses the property instead of the property. To rotate the brush about its center, the example sets the and properties of the object to absolute coordinates. Because the brush paints a rectangle that is 175 by 90 pixels, the center point of the rectangle is (87.5, 45). [!code-csharp[BrushesIntroduction_snip#ImageBrushTransformExample](~/samples/snippets/csharp/VS_Snippets_Wpf/BrushesIntroduction_snip/CSharp/BrushTransformExample.cs#imagebrushtransformexample)] [!code-vb[BrushesIntroduction_snip#ImageBrushTransformExample](~/samples/snippets/visualbasic/VS_Snippets_Wpf/BrushesIntroduction_snip/visualbasic/brushtransformexample.vb#imagebrushtransformexample)] [!code-xaml[BrushesIntroduction_snip#ImageBrushTransformExample](~/samples/snippets/xaml/VS_Snippets_Wpf/BrushesIntroduction_snip/XAML/BrushTransformExample.xaml#imagebrushtransformexample)] For a description of how the and properties work, see the [Brush Transformation Overview](brush-transformation-overview.md). For the complete sample, see [Brushes Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Graphics/Brushes). For more information about brushes, see [Painting with Solid Colors and Gradients Overview](painting-with-solid-colors-and-gradients-overview.md). ## See also - [Brush Transformation Overview](brush-transformation-overview.md) - [Painting with Solid Colors and Gradients Overview](painting-with-solid-colors-and-gradients-overview.md) - [Transforms Overview](transforms-overview.md)