Defining Style Resources

The simplest form of styling your user interface is to assign values to properties exposed by controls, using attribute syntax. However, this will very soon lead to your XAML becoming an unmaintainable mess. Doing so will result in your XAML files becoming unwieldy, complex, and hard to read; and any necessary styling changes will often need to be made in numerous places within the application—essentially, you will have spaghetti XAML code.

The answer to this problem is to use style resources. Defining and using style resources has numerous advantages. If we want to change the styling of all our TextBox controls, we only need to set the value in one place, and it will automatically be applied to all the controls that ...

Get Pro Business Applications with Silverlight 5 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.