O'Reilly logo

Beginning Windows® Phone 7 Application Development: Building Windows® Phone Applications Using Silverlight® and XNA® by Robert Fonseca-Ensor, Karli Watson, Nick Lecrenski

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

THEMES AND RESOURCES

You can easily restyle applications and controls in the Silverlight framework. (This process is also known as skinning, or theming.) Blend makes this restyling even easier, as explained in this section.

Managing Resources

In Silverlight, a Resource is simply an object that's declared in a ResourceDictionary in XAML. Because it's in the ResourceDictionary, it's made available to all the children of the item that owns that ResourceDictionary. This means that if you declare a resource in the ResourceDictionary of a Page, you can use that resource from anywhere in that page. In XAML, you access the value of a resource with the syntax {StaticResource keyName}, where keyName is the key name chosen for the resource (with the syntax x:Key=“keyName”).

Using resources is a perfect way to reuse objects and values in Silverlight. You can specify something once, reference it from multiple places, and when you update the original resource in Blend or Visual Studio all the references will reflect these changes.

Making Your Own Resources

Blend makes it easy to work with resources. Most property values can be extracted into a resource: In the property's Advanced Options menu (the peg, discussed earlier in this chapter, in the sidebar “Property Pegs”), there's an option called Convert to New Resource. Invoking this brings up a dialog from which you can pick a name for the resource and choose where to keep it. This dialog lets you keep the resource in a number of places:

  • Application ...

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