Monthly Archives: November 2010

Manipulating Styles At Runtime in Silverlight

I’ve been writing a 4 part series on everything (I think) is worth knowing about styles in Silverlight. The previous parts were Silverlight Styles: an Introduction, Silverlight Styles: Advanced Topics and Silverlight Styles: Further Advanced Topics

The final part of the series is ready and it covers the following topics:

  • Modifying Styles Runtime: the IsSealed Property – modifying the Setters of a Style can only be done if the IsSealed property is set to false and this property is set to true as soon as the style gets applied to an element in the visual tree.
  • Cloning Styles – because sealed Styles can’t be modified, one needs to clone them to be able to manipulate them. I’m providing example code on how cloning of a Style can be done.
  • Merging styles runtime – I’m showing two ways of merging existing styles programatically, both using the BasedOn property of Style as well as just copying Style setters.

You can read the detailed article and download source code for examples on my Visiblox blog – I hope you’ll find it useful.

 Scroll to top