Using x:Name or Name in WPF [duplicate]
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.
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.
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.
You're safer using x:Name because it works all the time, where as Name depends on the particular control implementation.
精彩评论