ContentPropertyAttribute is an attribute that a class author places on the class to specify the property that is the ContentProperty. As an example, here's part of the declaration of the Style class:
When a property is the ContentProperty for a class, it becomes the property that takes the content of the element, as written in XAML. In that way, it provides a XAML shortcut.
For example, you may have the following XAML:
<Style TargetType="TextBox">
<Style.Setters>
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="25"/>
</Style.Setters>
<Style.Triggers>
<!-- Triggers go here-->
</Style.Triggers>
</Style>
The above is equivalent to the following:
Notice that the <Style.Setters/> tags can be omitted because Setters is the ContentProperty.
For your convenience, here’s the list of properties with the attribute set (thanks to our teammate Michael for generating the list). The subclasses are not listed here but these are applicable to the subclasses as well (e.g. ListBox is an ItemsControl so the Items property is the ContentProperty for ListBox).
AccessText.Text
AdornedElementPlaceholder.Child
AnchoredBlock.Blocks
ArrayExtension.Items
BeginStoryboard.Storyboard
BitmapEffectGroup.Children
BlockUIContainer.Child
ContentControl.Content
DataTrigger.Setters
Decorator.Child
DocumentViewerBase.Document
DrawingGroup.Children
EventTrigger.Actions
FixedDocument.Pages
FixedDocumentSequence.References
FixedPage.Children
FlowDocument.Blocks
FlowDocumentReader.Document
FlowDocumentScrollViewer.Document
Frame.Content
FrameworkTemplate.VisualTree
GeneralTransformGroup.Children
GeometryGroup.Children
GradientBrush.GradientStops
GridView.Columns
GridViewColumn.Header
InkCanvas.Children
InlineUIContainer.Child
ItemsControl.Items
List.ListItems
ListItem.Blocks
MaterialGroup.Children
Model3DGroup.Children
ModelVisual3D.Children
MultiBinding.Bindings
MultiDataTrigger.Setters
MultiTrigger.Setters
NavigationWindow.Content
Page.Content
PageContent.Child
Panel.Children
Paragraph.Inlines
PathFigure.Segments
PathGeometry.Figures
Popup.Child
PriorityBinding.Bindings
RichTextBox.Document
Run.Text
Section.Blocks
Span.Inlines
Style.Setters
Table.RowGroups
TableCell.Blocks
TableRow.Cells
TableRowGroup.Rows
TextBlock.Inlines
TextBox.Text
ThicknessAnimationUsingKeyFrames.KeyFrames
ToolBarTray.ToolBars
Transform3DGroup.Children
TransformGroup.Children
Trigger.Setters
VectorAnimationUsingKeyFrames.KeyFrames
Viewport3D.Children
Viewport3DVisual.Children
XmlDataProvider.XmlSerializer
Happy Holidays from the WPF SDK team!
Tina