Prev | Current Page 132 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"


Nested content doesn??™t always indicate a collection. For example, consider the Grid
element, which contains several other controls:

...

...



...


These nested tags don??™t correspond to complex properties because they don??™t include the
period. Furthermore, the Grid control isn??™t a collection and so it doesn??™t implement IList or
IDictionary. What the Grid does support is the ContentProperty attribute, which indicates the
property that should receive any nested content. Technically, the ContentProperty attribute is
applied to the Panel class, from which the Grid derives, and looks like this:
_
Public MustInherit Class Panel
This indicates that any nested elements should be used to set the Children property. The
XAML parser treats the content property differently depending on whether or not it??™s a collection
property (in which case it implements the IList or IDictionary interface). Because the
CHAPTER 2 n XAML 40
Panel.Children property returns a UIElementCollection, and because UIElementCollection
implements IList, the parser uses the IList.Add() method to add nested content to the grid.


Pages:
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144