Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-find-the-source-element-in-an-event-handler.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

1.5 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Find the Source Element in an Event Handler 03/30/2017
csharp
vb
source element in event handlers [WPF]
event handlers [WPF], finding source element in
85f71c5a-b714-4c65-9711-7d905c2bbe98

How to: Find the Source Element in an Event Handler

This example shows how to find the source element in an event handler.

Example

The following example shows a xref:System.Windows.Controls.Primitives.ButtonBase.Click event handler that is declared in a code-behind file. When a user clicks the button that the handler is attached to, the handler changes a property value. The handler code uses the xref:System.Windows.RoutedEventArgs.Source%2A property of the routed event data that is reported in the event arguments to change the xref:System.Windows.FrameworkElement.Width%2A property value on the xref:System.Windows.RoutedEventArgs.Source%2A element.

[!code-xamlRoutedEventSource#XAMLHandler]

[!code-csharpRoutedEventSource#Handler] [!code-vbRoutedEventSource#Handler]

See also