"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"
]
[Answer will appear here.]
Attached properties aren??™t really properties at all. They??™re actually translated into method calls. The XAML parser calls the shared method that has this form: DefiningType.SetPropertyName(). For example, in the previous XAML snippet, the defining type is the Grid class, and the property is Row, so the parser calls Grid.SetRow(). When calling SetPropertyName(), the parser passes two parameters: the object that??™s being modified, and the property value that??™s specified. For example, when you set the Grid.Row property on the TextBox control, the XAML parser executes this code: Grid.SetRow(txtQuestion, 0) This pattern (calling a shared method of the defining type) is a convenience that conceals what??™s really taking place. To the casual eye, this code implies that the row number is stored in the Grid object. However, the row number is actually stored in the object that it applies to??”in this case, the TextBox object. This sleight of hand works because the TextBox derives from the DependencyObject base class, as do all WPF controls. And as you??™ll learn in Chapter 6, the DependencyObject is designed to store a virtually unlimited collection of dependency properties.