Synopsis: | Do use x:Name instead of Name to give XAML elements a unique name |
Language: | XAML |
Severity Level: | 1 |
Category: | Naming Conventions |
Description: |
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.
✘
✔ |