Bug 54416 - Named font sizes applied from static resources using onplatform not being applied
Summary: Named font sizes applied from static resources using onplatform not being app...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.3
Hardware: Macintosh All
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-04-03 18:21 UTC by Anders Bech Mellson
Modified: 2017-05-30 10:03 UTC (History)
6 users (show)

Tags: onplatform, fontsize, namedsize, xaml
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Anders Bech Mellson 2017-04-03 18:21:49 UTC
Setting the font size of a label using one of the named sizes in xaml either via a style or via onplatform is not working.

If I set the named size directly on a label element the size is applied ok.
But if I try to use a style or set the size using onplatform the size is not applied and the default size is used.

I have a thread about the problem here: https://forums.xamarin.com/discussion/comment/263653#Comment_263653
And a small repo showing the problem here: https://github.com/appbureauet/NamedSizeTest
Comment 1 Jimmy [MSFT] 2017-04-04 17:41:06 UTC
Thank you for reporting this! Let me confirm that I can reproduce the issue with the project you linked to and I will update the report with my results.
Comment 2 Jimmy [MSFT] 2017-04-04 19:10:17 UTC
I was able to reproduce this issue with the project on GitHub. 

The following works:

<Setter Property="FontSize" Value="Large" />

However it's when trying to also use OnPlatform that the issue occurs:

<Setter Property="FontSize">
    <OnPlatform x:TypeArguments="x:String"
        Android="Medium"
        iOS="Medium"
        WinPhone="Medium"/>
</Setter>

I am confirming the report so the team can investigate further and determine whether or not this is expected behavior.


### Workaround
A workaround you can do is to set the Font property instead of FontSize:

<Setter Property="Font">
    <OnPlatform x:TypeArguments="Font"
        Android="Large"
        iOS="Large"
        WinPhone="Large"/>
</Setter>

This should work in the meantime, however be cautioned that the Font property has been deprecated so its usage may break the app in a future update.


### Version Tests
2.3.4-pre6      BAD
2.3.3.193       BAD
Comment 3 Anders Bech Mellson 2017-04-05 06:22:40 UTC
Hi Jimmy, thanks for the update.

And thanks for the workaround using the Font property.
I actually did try that, but when I tried it I used it to set multiple attributes like so:

<Setter Property="Font">
    <OnPlatform x:TypeArguments="Font"
        Android="Large"
        iOS="Large, Bold"
        WinPhone="Large, Italic"/>
</Setter>

And then it doesn't work. But only setting the size seems to work for now.
Comment 4 NMackay 2017-05-25 10:33:38 UTC
Still exist in 2.3.4 stable.

Makes styling the app pretty much impossible with a XAML style.
Comment 5 NMackay 2017-05-25 10:51:01 UTC
Can work round it with OnPlatForm and FontSize but that bug does exists still.
Comment 6 Jimmy [MSFT] 2017-05-25 20:16:28 UTC
This appears to be resolved in 2.3.5. I ran the sample project in the description using 2.3.5-pre3 and the Labels used the expected FontSize. This works using both the old and new OnPlatform syntax. 

Can you confirm that it is also working for you with 2.3.5-pre3? Thanks!
Comment 7 Anders Bech Mellson 2017-05-29 07:02:42 UTC
I can confirm that it is working with 2.3.5.239-pre3.
Thanks!
Comment 8 Rui Marinho 2017-05-30 10:03:36 UTC
Fixed on 2.3.5.239-pre3