--- title: "How to: Apply a Transform to an Element When an Event Occurs" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "graphics [WPF], transformations as event responses" - "properties [WPF], LayoutTransform" - "transformations as event responses [WPF]" - "properties [WPF], RenderTransform" - "LayoutTransform property [WPF]" ms.assetid: 71e4327e-ca57-444c-a3cf-09fb381491a0 --- # How to: Apply a Transform to an Element When an Event Occurs This example shows how to apply a when an event occurs. The concept that is shown here is the same that you use for applying other types of transformations. For more information about the available types of transformations, see the class or [Transforms Overview](transforms-overview.md). You can apply a transform to an element in either of these two ways: - If you do *not* want the transform to affect layout, use the property of the element. - If you do want the transform to affect layout, use the property of the element. The following example applies a to the property of a button. When the mouse moves over the button, the and properties of the are set to `2`, which causes the button to become larger. When the mouse moves off the button, and are set to `1`, which causes the button to return to its original size. ## Example [!code-xaml[ButtonTransform#1](~/samples/snippets/csharp/VS_Snippets_Wpf/ButtonTransform/CSharp/ButtonTransformExample.xaml#1)] [!code-csharp[ButtonTransform#1cb](~/samples/snippets/csharp/VS_Snippets_Wpf/ButtonTransform/CSharp/ButtonTransformExample.xaml.cs#1cb)] [!code-vb[ButtonTransform#1cb](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ButtonTransform/VisualBasic/ButtonTransformExample.xaml.vb#1cb)] ## See also - - - [Transforms Overview](transforms-overview.md) - [How-to Topics](transformations-how-to-topics.md) - [Routed Events Overview](../advanced/routed-events-overview.md)