* 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
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 |
|
|
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:
-
If you do not want the transform to affect layout, use the xref:System.Windows.UIElement.RenderTransform%2A property of the element.
-
If you do want the transform to affect layout, use the xref:System.Windows.FrameworkElement.LayoutTransform%2A property of the element.
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]