Gets or sets the identifying name of the element. The name provides an instance reference so that programmatic code-behind, such as event handler code, can refer to an element once it is constructed during parsing of XAML.
Assembly: PresentationFramework (in PresentationFramework.dll)
The most common usage of this property is when specifying a XAML element name in markup.
This property essentially provides a WPF framework-level convenience property to set the XAML x:Name Directive.
Getting afrom code is not common, because if you have the appropriate reference in code already, you can just call methods and properties on the element reference and do not generally need the . An exception is if the string has some overloaded meaning, for instance if it is useful to display that name in UI. Setting a from code if the original was set from markup is also not recommended, and changing the property will not change the object reference. Such object references are created only when the underlying namescopes are explicitly created during XAML loading.
You must specifically call RegisterName to make an effective change on the property of an already loaded element.
Setting FindName, which is available from any FrameworkContentElement, can find any element by in that element's logical tree recursively. Or you can use the FindLogicalNode static method of LogicalTreeHelper, which also takes the string as an argument.from code has limited applications, but looking up an element by name is more common, particularly if you are employing a navigation model where pages reload into the application and the run-time code is not necessarily the code-behind of that respective page. The utility method
Available since 3.0