--- title: "How to: Find an Element by Its Name" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "elements [WPF], finding by name" ms.assetid: cfa7cf35-8aa2-4060-9454-872ed4af3f0e --- # How to: Find an Element by Its Name This example describes how to use the method to find an element by its 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 of the root being searched, and the example method then visually indicates the found element by casting it as and changing one of the visible [!INCLUDE[TLA2#tla_ui](../../../includes/tla2sharptla-ui-md.md)] properties. [!code-csharp[FEFindName#Find](~/samples/snippets/csharp/VS_Snippets_Wpf/FEFindName/CSharp/default.xaml.cs#find)] [!code-vb[FEFindName#Find](~/samples/snippets/visualbasic/VS_Snippets_Wpf/FEFindName/VisualBasic/default.xaml.vb#find)]