1.

What are Attached properties in WPF?

Answer»

An attached property is a concept in XAML (Extensible Application Markup Language). ESSENTIALLY, these properties ENABLE you to assign extra properties/values to any XAML element, even if it doesn't define them in its object model. As a special type of DependencyProperty, you can apply it to any DependencyObject to enhance the behavior of various controls and services. Attached properties would be useful in the following cases: 

  • When parent ELEMENTS iterate its child object and act UPON them in a certain way. Grid controls, for example, organize elements into ROWS and columns using its Grid.Row, Grid.RowSpan, Grid.Column and Grid.ColumnSpan attached properties.
  • When adding visuals to existing controls using custom templates.
  • The addition of generic features/services to existing controls, for example, ToolTipService and FocusManager. They are called attached behaviors.


Discussion

No Comment Found