Bug 41093 - implicit styles are not applied
Summary: implicit styles are not applied
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.0.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-05-15 22:03 UTC by Alessandro
Modified: 2017-01-27 12:10 UTC (History)
3 users (show)

Tags: ac
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 ANSWERED

Description Alessandro 2016-05-15 22:03:19 UTC
I have tried this code on iOS emulator

var buttonStyle = new Style (typeof(Button)) {
Setters = {new Setter { Property = Button.FontSizeProperty,   
Value  = Font.SystemFontOfSize (NamedSize.Large) }}};

it does not change font size.



this code change font size

var buttonStyle = new Style (typeof(Button)) {
Setters = {new Setter { Property = Button.FontSizeProperty,   
Value  = 30 }}};


this code make button invisible

var buttonStyle = new Style (typeof(Button)) {
Setters = {new Setter { Property = Button.FontSizeProperty,   
Value  = Font.SystemFontOfSize (NamedSize.Large).FontSize }}};
Comment 1 Stephane Delcroix 2017-01-27 12:10:07 UTC
Font.SystemFontOfSize (NamedSize.Large) returns a Font, not a FontSize, that's why the first setter is not applied.

The second works.

About the third... SystemOfFontSize doesn't return a Font with the FontSize set, but with the NamedSize set. you can convert the NamedSize to double using Device.GetNamedSize().

So this is the Style you want:

var buttonStyle = new Style(typeof(Button)) {
	Setters = {new Setter { Property = Button.FontSizeProperty, Value  = Device.GetNamedSize(Font.SystemFontOfSize (NamedSize.Large).NamedSize, typeof(Button)) }}
};