The title says it all. Sometimes it seems that the Name
and x:Name
attributes are interchangeable.
So, what are the definitive differences
They are not the same thing.
x:Name
is a xaml concept, used mainly to reference elements. When you give an element the x:Name xaml attribute, "the specified x:Name
becomes the name of a field that is created in the underlying code when xaml is processed, and that field holds a reference to the object." (MSDN) So, it's a designer-generated field, which has internal access by default.
Name
is the existing string property of a FrameworkElement
, listed as any other wpf element property in the form of a xaml attribute.
As a consequence, this also means x:Name
can be used on a wider range of objects. This is a technique to enable anything in xaml to be referenced by a given name.