Prev | Current Page 131 | Next

Matthew MacDonald

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

However, it needs to process the tags inside (the three
GradientStop elements) a little differently. In this case, the parser recognizes that the GradientStops
property returns a GradientStopCollection object, and the GradientStopCollection
implements the IList interface. Thus, it assumes (quite rightly) that each GradientStop should
be added to the collection using the IList.Add() method:
Dim gradientStop1 As New GradientStop()
gradientStop1.Offset = 0
gradientStop1.Color = Colors.Red
Dim list As IList = brush.GradientStops
list.Add(gradientStop1)
CHAPTER 2 n XAML 39
Some properties might support more than one type of collection. In this case, you need to
add a tag that specifies the collection class, like this:









nNote If the collection defaults to a null reference (Nothing), you need to include the tag that specifies the
collection class, thereby creating the collection object. If there??™s a default instance of the collection and you
simply need to fill it, you can omit that part.


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