views:

32

answers:

1

In WPF I could apply a style to a target type without giving it a name. This would effectively style all elements of that type without explicitly setting the style on each button.

    <Style TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="White" />
    </Style>

    <Button Content="Button1"></Button>

This seems to be giving me problems within WP7 SL as the style is not applied unless I give it an x:Name and set the style on each instance.

    <Style x:Key="btnStyle" TargetType="Button">
        <Setter Property="BorderBrush" Value="Red" />
    </Style>

Is this a chore that I will have to suffer or is there a workaround?

+1  A: 

As far as I know, what you have observed in WP7 XAML is inherited from Silverlight. WP7 Silverlight is based on Silverlight 3 and some bits of Silverlight 4.Styles need to be explicitly applied, although this may seem to be too verbose, I personally find defining styles and using them to be best for maintenance of the code.

HTH, indyfromoz

indyfromoz
Okay thanks. :)
Kohan