O'Reilly logo

Microsoft® Silverlight® Edition: Programming Windows® Phone 7 by Charles Petzold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Content and Content Properties

Everyone knows that XML can be a little “wordy.” However, the markup I’ve shown you with the gradient brushes is a little wordier than it needs to be. Let’s look at the RadialGradientBrush I originally defined for the TextBlock:

<TextBlock.Foreground>
    <RadialGradientBrush>
        <RadialGradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Offset="0" Color="Transparent" />
                <GradientStop Offset="1" Color="Red" />
            </GradientStopCollection>
        </RadialGradientBrush.GradientStops>
    </RadialGradientBrush>
</TextBlock.Foreground>

First, if you have at least one item in a collection, you can eliminate the tags for the collection itself. This means that the tags for the GradientStopCollection can be removed:

<TextBlock.Foreground> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required