funwithcoding
funwithcoding

Reputation: 2412

Silverlight 3 : How to apply a style to all controls of a particular type(ex:TextBlock)?

Silverlight 3 : How to apply a style to all controls of a particular type(ex:TextBlock) ? I know that it is possible in WPF but how about silverlight?

for example this my style

    <Style x:Key="TextBlockStyle1" TargetType="TextBlock">
   <Setter Property="FontWeight" Value="Bold"/>
  </Style>

I tried removing the x:Key="TextBlockStyle1" and made it like the following

    <Style TargetType="TextBlock">
   <Setter Property="FontWeight" Value="Bold"/>
  </Style>

this did not work, bold is not applied to textblocks :(. Any help is appreciated.

Upvotes: 0

Views: 908

Answers (2)

Lars Udengaard
Lars Udengaard

Reputation: 1267

The Silverlight Toolkit guys have made a implicit style manager for Silverlight 3. See http://silverlight.codeplex.com/wikipage?title=Silverlight%20Toolkit%20Overview%20Part%203&referringTitle=Home&ANCHOR#ImplicitStyleManager

You wont save any space in your XAML files, since you still have to define usage of the implicit style on your controls. But it gives the benefit of making general styling which is centralized and easily maintained.

Upvotes: 2

Michael S. Scherotter
Michael S. Scherotter

Reputation: 10785

Implicit Styles will be a feature of Silverlight 4 which will be released in the first half of 2010.

Upvotes: 1

Related Questions