TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
XAML Coding Standard

NAM$003Checked automatically with code checker

Synopsis:Do use x:Name instead of Name to give XAML elements a unique name
Severity Level:1
Category:Naming Conventions


At first sight, the x:Name and Name properties appear to be the same, but in fact they are not. The x:Name directive is used to uniquely identify XAML elements in a XAML name scope. The Name, on the other hand, is a property of WPF's FrameworkElement class. However, since not all XAML elements represent FrameworkElement instances, it will not always work to assign the Name property to a XAML element. This means that x:Name can be used on a wider range of objects, and is the preferred way of giving XAML elements a unique name.

  <Button Name="cancelButton"/>

  <Button x:Name="cancelButton"/>