views:

182

answers:

2

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.

+1  A: 

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

Michael S. Scherotter
That sounds good.Looking forward for the future. :)
funwithcoding
+2  A: 

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&amp;referringTitle=Home&amp;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.

Lars Udengaard