17

My understanding of x:Name vs Name is that some controls have a Name property, that is basically the same as setting x:Name.

Is there an advantage to using Name when it is available over x:Name?

Here's my reference for understanding x:Name vs Name.

1
  • Sorry ... I did search for this question as I was sure it must have been asked already, but I couldn't find it. Commented Dec 18, 2009 at 19:59

3 Answers 3

12

For any that has stumbled upon this question ... here's is a very detailed answer. Thanks to Taylor L for pointing me in the right direction.

Sign up to request clarification or add additional context in comments.

Comments

7

If Name is available as a property on the class, Name and x:Name can be used interchangeably as attributes, but an error will result if both are specified on the same element.

Source: x:Name Attribute

In other words, it makes no difference which one you use; just don't use both on the same element.

1 Comment

Sometimes it makes a difference: stackoverflow.com/questions/1380112/…
7

You're safer using x:Name because it works all the time, where as Name depends on the particular control implementation.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.