I am working on applying global font styles to my application right now. I do this using the following code:
<Style TargetType="Button">
<Setter Property="FontFamily">
<Setter.Value>
<OnPlatform x:TypeArguments="x:String"
iOS="HelveticaNeue"
Android="sans-serif"/>
</Setter.Value>
</Setter>
</Style>
This works great and styles the buttons with a FontFamily
. I am also setting named styles on certain buttons using the following code:
<Style x:Key="BaseButtonStyle" TargetType="Button">
<Setter Property="BackgroundColor" Value="Transparent"/>
<Setter Property="BorderWidth" Value="1"/>
<Setter Property="BorderColor" Value="{x:Static map:Constants.Blue}"/>
</Style>
The named styles override the global styles as expected but I guess I was hoping that they would only override the styled properties that actually overlap (if I was, for example, specifying a FontFamily
in both the global style and the named style).
Is this expected behavior for a named style to override properties that are not even being defined? It is a fairly simple workaround to just add the FontFamily
style into all of my named styles but I wanted to see what other people think of this. Thanks.