Can't get FontSize for labels to work in ResourceDictionary when using OnPlatform












0















When using <Style TargetType="Label"> I cant get FontSize to work with NamedSize.



Using Xamarin.Forms version : 3.4.0.1008975



Working :



<Style TargetType="Label">
<Setter Property="FontSize" Value="Small" />
</Style>


NOT working :



<Style TargetType="Label">
<Setter Property="FontSize">
<Setter.Value>
<OnPlatform x:TypeArguments="x:String"
Android="Small"
iOS="Medium"/>
</Setter.Value>
</Setter>
</Style>


I have tried to change the TypeArguments to <OnPlatform x:TypeArguments="NamedSize" .../> with no success.



I am using other propertysetters with <OnPlatform .../> and they work as they should. Its just FontSize.










share|improve this question























  • I think you are trying to use DynamicResource which seems to have limitation. Check this solution: https://forums.xamarin.com/discussion/65252/dynamicresource-limitation-for-onplatform-in-xaml-xamarin-forms

    – Prateek
    Nov 21 '18 at 16:23
















0















When using <Style TargetType="Label"> I cant get FontSize to work with NamedSize.



Using Xamarin.Forms version : 3.4.0.1008975



Working :



<Style TargetType="Label">
<Setter Property="FontSize" Value="Small" />
</Style>


NOT working :



<Style TargetType="Label">
<Setter Property="FontSize">
<Setter.Value>
<OnPlatform x:TypeArguments="x:String"
Android="Small"
iOS="Medium"/>
</Setter.Value>
</Setter>
</Style>


I have tried to change the TypeArguments to <OnPlatform x:TypeArguments="NamedSize" .../> with no success.



I am using other propertysetters with <OnPlatform .../> and they work as they should. Its just FontSize.










share|improve this question























  • I think you are trying to use DynamicResource which seems to have limitation. Check this solution: https://forums.xamarin.com/discussion/65252/dynamicresource-limitation-for-onplatform-in-xaml-xamarin-forms

    – Prateek
    Nov 21 '18 at 16:23














0












0








0








When using <Style TargetType="Label"> I cant get FontSize to work with NamedSize.



Using Xamarin.Forms version : 3.4.0.1008975



Working :



<Style TargetType="Label">
<Setter Property="FontSize" Value="Small" />
</Style>


NOT working :



<Style TargetType="Label">
<Setter Property="FontSize">
<Setter.Value>
<OnPlatform x:TypeArguments="x:String"
Android="Small"
iOS="Medium"/>
</Setter.Value>
</Setter>
</Style>


I have tried to change the TypeArguments to <OnPlatform x:TypeArguments="NamedSize" .../> with no success.



I am using other propertysetters with <OnPlatform .../> and they work as they should. Its just FontSize.










share|improve this question














When using <Style TargetType="Label"> I cant get FontSize to work with NamedSize.



Using Xamarin.Forms version : 3.4.0.1008975



Working :



<Style TargetType="Label">
<Setter Property="FontSize" Value="Small" />
</Style>


NOT working :



<Style TargetType="Label">
<Setter Property="FontSize">
<Setter.Value>
<OnPlatform x:TypeArguments="x:String"
Android="Small"
iOS="Medium"/>
</Setter.Value>
</Setter>
</Style>


I have tried to change the TypeArguments to <OnPlatform x:TypeArguments="NamedSize" .../> with no success.



I am using other propertysetters with <OnPlatform .../> and they work as they should. Its just FontSize.







xaml xamarin.forms






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 13:06









Mattias GregerMattias Greger

317




317













  • I think you are trying to use DynamicResource which seems to have limitation. Check this solution: https://forums.xamarin.com/discussion/65252/dynamicresource-limitation-for-onplatform-in-xaml-xamarin-forms

    – Prateek
    Nov 21 '18 at 16:23



















  • I think you are trying to use DynamicResource which seems to have limitation. Check this solution: https://forums.xamarin.com/discussion/65252/dynamicresource-limitation-for-onplatform-in-xaml-xamarin-forms

    – Prateek
    Nov 21 '18 at 16:23

















I think you are trying to use DynamicResource which seems to have limitation. Check this solution: https://forums.xamarin.com/discussion/65252/dynamicresource-limitation-for-onplatform-in-xaml-xamarin-forms

– Prateek
Nov 21 '18 at 16:23





I think you are trying to use DynamicResource which seems to have limitation. Check this solution: https://forums.xamarin.com/discussion/65252/dynamicresource-limitation-for-onplatform-in-xaml-xamarin-forms

– Prateek
Nov 21 '18 at 16:23












1 Answer
1






active

oldest

votes


















0














<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App67"
x:Class="App67.MainPage">

<ContentPage.Resources>
<OnPlatform x:Key="textColor"
x:TypeArguments="Color">
<On Platform="WinPhone" Value="Red" />
<On Platform="Android" Value="Aqua" />
<On Platform="iOS" Value="#80FF80" />
</OnPlatform>
<OnPlatform x:Key="fontSize"
x:TypeArguments="Font">
<On Platform="WinPhone" Value="Bold,Large" />
<On Platform="Android" Value="Bold,Large" />
<On Platform="iOS" Value="Bold,Large" />
</OnPlatform>

</ContentPage.Resources>

<ContentPage.Content>
<StackLayout>
<Label Text="Check out my style." TextColor="{StaticResource textColor}" Font="{StaticResource fontSize}" />
</StackLayout>
</ContentPage.Content>

</ContentPage>





share|improve this answer


























  • Thanks for taking the time. That syntax doesn't seem to be working for me. Guessing they changed the OnPlatform in later Xamarin.Forms? Error XLS0415 The attachable property 'iOS' was not found in type 'OnPlatform'. Error XLS0415 The attachable property 'Android' was not found in type 'OnPlatform'. And Error XLS0515 All objects added to an IDictionary must have a Key attribute or some other type of key associated with them.

    – Mattias Greger
    Nov 27 '18 at 13:29













  • @MattiasGreger I modified my answer, you can check it.

    – AbbyWang - MSFT
    Nov 28 '18 at 2:48











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412719%2fcant-get-fontsize-for-labels-to-work-in-resourcedictionary-when-using-onplatfor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App67"
x:Class="App67.MainPage">

<ContentPage.Resources>
<OnPlatform x:Key="textColor"
x:TypeArguments="Color">
<On Platform="WinPhone" Value="Red" />
<On Platform="Android" Value="Aqua" />
<On Platform="iOS" Value="#80FF80" />
</OnPlatform>
<OnPlatform x:Key="fontSize"
x:TypeArguments="Font">
<On Platform="WinPhone" Value="Bold,Large" />
<On Platform="Android" Value="Bold,Large" />
<On Platform="iOS" Value="Bold,Large" />
</OnPlatform>

</ContentPage.Resources>

<ContentPage.Content>
<StackLayout>
<Label Text="Check out my style." TextColor="{StaticResource textColor}" Font="{StaticResource fontSize}" />
</StackLayout>
</ContentPage.Content>

</ContentPage>





share|improve this answer


























  • Thanks for taking the time. That syntax doesn't seem to be working for me. Guessing they changed the OnPlatform in later Xamarin.Forms? Error XLS0415 The attachable property 'iOS' was not found in type 'OnPlatform'. Error XLS0415 The attachable property 'Android' was not found in type 'OnPlatform'. And Error XLS0515 All objects added to an IDictionary must have a Key attribute or some other type of key associated with them.

    – Mattias Greger
    Nov 27 '18 at 13:29













  • @MattiasGreger I modified my answer, you can check it.

    – AbbyWang - MSFT
    Nov 28 '18 at 2:48
















0














<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App67"
x:Class="App67.MainPage">

<ContentPage.Resources>
<OnPlatform x:Key="textColor"
x:TypeArguments="Color">
<On Platform="WinPhone" Value="Red" />
<On Platform="Android" Value="Aqua" />
<On Platform="iOS" Value="#80FF80" />
</OnPlatform>
<OnPlatform x:Key="fontSize"
x:TypeArguments="Font">
<On Platform="WinPhone" Value="Bold,Large" />
<On Platform="Android" Value="Bold,Large" />
<On Platform="iOS" Value="Bold,Large" />
</OnPlatform>

</ContentPage.Resources>

<ContentPage.Content>
<StackLayout>
<Label Text="Check out my style." TextColor="{StaticResource textColor}" Font="{StaticResource fontSize}" />
</StackLayout>
</ContentPage.Content>

</ContentPage>





share|improve this answer


























  • Thanks for taking the time. That syntax doesn't seem to be working for me. Guessing they changed the OnPlatform in later Xamarin.Forms? Error XLS0415 The attachable property 'iOS' was not found in type 'OnPlatform'. Error XLS0415 The attachable property 'Android' was not found in type 'OnPlatform'. And Error XLS0515 All objects added to an IDictionary must have a Key attribute or some other type of key associated with them.

    – Mattias Greger
    Nov 27 '18 at 13:29













  • @MattiasGreger I modified my answer, you can check it.

    – AbbyWang - MSFT
    Nov 28 '18 at 2:48














0












0








0







<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App67"
x:Class="App67.MainPage">

<ContentPage.Resources>
<OnPlatform x:Key="textColor"
x:TypeArguments="Color">
<On Platform="WinPhone" Value="Red" />
<On Platform="Android" Value="Aqua" />
<On Platform="iOS" Value="#80FF80" />
</OnPlatform>
<OnPlatform x:Key="fontSize"
x:TypeArguments="Font">
<On Platform="WinPhone" Value="Bold,Large" />
<On Platform="Android" Value="Bold,Large" />
<On Platform="iOS" Value="Bold,Large" />
</OnPlatform>

</ContentPage.Resources>

<ContentPage.Content>
<StackLayout>
<Label Text="Check out my style." TextColor="{StaticResource textColor}" Font="{StaticResource fontSize}" />
</StackLayout>
</ContentPage.Content>

</ContentPage>





share|improve this answer















<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App67"
x:Class="App67.MainPage">

<ContentPage.Resources>
<OnPlatform x:Key="textColor"
x:TypeArguments="Color">
<On Platform="WinPhone" Value="Red" />
<On Platform="Android" Value="Aqua" />
<On Platform="iOS" Value="#80FF80" />
</OnPlatform>
<OnPlatform x:Key="fontSize"
x:TypeArguments="Font">
<On Platform="WinPhone" Value="Bold,Large" />
<On Platform="Android" Value="Bold,Large" />
<On Platform="iOS" Value="Bold,Large" />
</OnPlatform>

</ContentPage.Resources>

<ContentPage.Content>
<StackLayout>
<Label Text="Check out my style." TextColor="{StaticResource textColor}" Font="{StaticResource fontSize}" />
</StackLayout>
</ContentPage.Content>

</ContentPage>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 28 '18 at 2:46

























answered Nov 22 '18 at 7:07









AbbyWang - MSFTAbbyWang - MSFT

51915




51915













  • Thanks for taking the time. That syntax doesn't seem to be working for me. Guessing they changed the OnPlatform in later Xamarin.Forms? Error XLS0415 The attachable property 'iOS' was not found in type 'OnPlatform'. Error XLS0415 The attachable property 'Android' was not found in type 'OnPlatform'. And Error XLS0515 All objects added to an IDictionary must have a Key attribute or some other type of key associated with them.

    – Mattias Greger
    Nov 27 '18 at 13:29













  • @MattiasGreger I modified my answer, you can check it.

    – AbbyWang - MSFT
    Nov 28 '18 at 2:48



















  • Thanks for taking the time. That syntax doesn't seem to be working for me. Guessing they changed the OnPlatform in later Xamarin.Forms? Error XLS0415 The attachable property 'iOS' was not found in type 'OnPlatform'. Error XLS0415 The attachable property 'Android' was not found in type 'OnPlatform'. And Error XLS0515 All objects added to an IDictionary must have a Key attribute or some other type of key associated with them.

    – Mattias Greger
    Nov 27 '18 at 13:29













  • @MattiasGreger I modified my answer, you can check it.

    – AbbyWang - MSFT
    Nov 28 '18 at 2:48

















Thanks for taking the time. That syntax doesn't seem to be working for me. Guessing they changed the OnPlatform in later Xamarin.Forms? Error XLS0415 The attachable property 'iOS' was not found in type 'OnPlatform'. Error XLS0415 The attachable property 'Android' was not found in type 'OnPlatform'. And Error XLS0515 All objects added to an IDictionary must have a Key attribute or some other type of key associated with them.

– Mattias Greger
Nov 27 '18 at 13:29







Thanks for taking the time. That syntax doesn't seem to be working for me. Guessing they changed the OnPlatform in later Xamarin.Forms? Error XLS0415 The attachable property 'iOS' was not found in type 'OnPlatform'. Error XLS0415 The attachable property 'Android' was not found in type 'OnPlatform'. And Error XLS0515 All objects added to an IDictionary must have a Key attribute or some other type of key associated with them.

– Mattias Greger
Nov 27 '18 at 13:29















@MattiasGreger I modified my answer, you can check it.

– AbbyWang - MSFT
Nov 28 '18 at 2:48





@MattiasGreger I modified my answer, you can check it.

– AbbyWang - MSFT
Nov 28 '18 at 2:48




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412719%2fcant-get-fontsize-for-labels-to-work-in-resourcedictionary-when-using-onplatfor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()