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

The Concept of Content

Button derives from Control but it also derives from ContentControl, which is the class that provides the button’s Content property. You can pull out the Content property as a property element:

<Button>
    <Button.Content>

    </Button.Content>
</Button>

But oddly enough you can’t put text in there:

<!-- Doesn't work! -->
<Button>
    <Button.Content>
        Click this button!
    </Button.Content>
</Button>

There’s nothing ostensibly wrong with that syntax but Silverlight doesn’t allow it. If you really want to do something like this you’ll need an XML namespace declaration for the System namespace:

xmlns:system="clr-namespace:System;assembly=mscorlib"

You can then put the string between tags that explicitly tell the XAML parser than the string is ...

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