Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-apply-a-transform-to-an-element-when-an-event-occurs.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.5 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Apply a Transform to an Element When an Event Occurs 03/30/2017
csharp
vb
graphics [WPF], transformations as event responses
properties [WPF], LayoutTransform
transformations as event responses [WPF]
properties [WPF], RenderTransform
LayoutTransform property [WPF]
71e4327e-ca57-444c-a3cf-09fb381491a0

How to: Apply a Transform to an Element When an Event Occurs

This example shows how to apply a xref:System.Windows.Media.ScaleTransform 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 xref:System.Windows.Media.Transform class or Transforms Overview.

You can apply a transform to an element in either of these two ways:

The following example applies a xref:System.Windows.Media.ScaleTransform to the xref:System.Windows.UIElement.RenderTransform%2A property of a button. When the mouse moves over the button, the xref:System.Windows.Media.ScaleTransform.ScaleX%2A and xref:System.Windows.Media.ScaleTransform.ScaleY%2A properties of the xref:System.Windows.Media.ScaleTransform are set to 2, which causes the button to become larger. When the mouse moves off the button, xref:System.Windows.Media.ScaleTransform.ScaleX%2A and xref:System.Windows.Media.ScaleTransform.ScaleY%2A are set to 1, which causes the button to return to its original size.

Example

[!code-xamlButtonTransform#1]

[!code-csharpButtonTransform#1cb] [!code-vbButtonTransform#1cb]

See also