WPF: Attached property

This entry is part 50 of 54 in the series Learn WPF

We have gone through an example on Dependency Property and unlike Dependency Property, attached property is meant for use in XAML.

One purpose of an attached property is to allow different child elements to specify unique values for a property that is actually defined in a parent element.

In XAML, they are always defined by using the syntax AttachedPropertyProvider.PropertyName

Consider the following example.

  <CheckBox DockPanel.Dock="Top">Hello</CheckBox>

DockPanel.Dock is an attached property of DockPanel.  With DockPanel.Dock, we can inform the DockPanel how we should postition the CheckBox.



Series Navigation<< WPF: Implementing dependency properties
WPF: Accessing attached properties >>