Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-find-an-element-by-its-name.md
T
Andy (Steve) De George be103da07e Replace various WPF include files with content (#1335)
* net-current-v30plus-md.md

* net-current-v40plus-md.md

* tla2sharptla-ui-md.md

* tla2sharptla-uiautomation-md.md

* tla2sharptla-winclient-md.md

* tla2sharptla-xaml-md.md

* tlasharptla-ui-md.md

* tlasharptla-uiautomation-md.md

* tlasharptla-winclient-md.md

* tlasharptla-xaml-md.md

* fix warnings
2022-03-16 12:14:11 -04:00

1.1 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Find an Element by Its Name 03/30/2017
csharp
vb
elements [WPF], finding by name
cfa7cf35-8aa2-4060-9454-872ed4af3f0e

How to: Find an Element by Its Name

This example describes how to use the xref:System.Windows.FrameworkElement.FindName%2A method to find an element by its xref:System.Windows.FrameworkElement.Name%2A value.

Example

In this example, the method to find a particular element by its name is written as the event handler of a button. stackPanel is the xref:System.Windows.FrameworkElement.Name%2A of the root xref:System.Windows.FrameworkElement being searched, and the example method then visually indicates the found element by casting it as xref:System.Windows.Controls.TextBlock and changing one of the xref:System.Windows.Controls.TextBlock visible UI properties.

[!code-csharpFEFindName#Find] [!code-vbFEFindName#Find]