开发者

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

开发者 https://www.devze.com 2022-12-20 06:11 出处:网络
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?

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开发者_C百科 to textblocks :(. Any help is appreciated.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号