The question now: what do I have to do that?
Let's look at a great example - layout.
Take the Grid
class. If we wanted to support this, every control would need to have a GridRow
and GridColumn
property. However, attached properties allow us to attach Grid.Row
to any control, which in turn allows the Grid
to layout that control within itself properly.
Attached properties all work in this basic way - they allow you to "attach" something that defines or helps some behavioral feature work properly without changing the "something" itself.