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

UNDERSTANDING CONTROL STYLES

If you've done any considerable amount of web development, especially using HTML, you've probably figured out the tremendous advantages of using CSS to control the look of various HTML elements in your website. CSS allows you to easily configure the various styles of controls, and its powerful cascading rules allow you to apply styles to multiple controls with minimal amounts of code. An additional benefit of CSS is that it allows you to separate the styles of the HTML elements from the HTML elements themselves. Although you can declare CSS style information inline next to the element to be affected, more often you put all the necessary style information in a separate file and include it at the top of the web page.

So far in this book, you've seen how to manipulate various Silverlight control styles by setting values for properties such as Background, BorderBrush, Margin, and Padding. All the work you've been doing has been inline and right next to the control being affected. In the following code, you can see how this would be a time-consuming task, especially with a set of Button controls that have similar style information:

<Button Margin=“10,10,5,5” Padding=“5” Background=“Beige” Foreground=“Black” Content=“Click Me” /> <Button Margin=“10,10,5,5” Padding=“5” Background=“Beige” Foreground=“Black” Content=“Click Me” /> <Button Margin=“10,10,5,5” Padding=“5” Background=“Beige” Foreground=“Black” Content=“Click Me” /> <Button Margin=“10,10,5,5” Padding=“5” ...

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