Can't get FontSize for labels to work in ResourceDictionary when using OnPlatform
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
add a comment |
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
I think you are trying to useDynamicResource
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
add a comment |
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
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
xaml xamarin.forms
asked Nov 21 '18 at 13:06
Mattias GregerMattias Greger
317
317
I think you are trying to useDynamicResource
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
add a comment |
I think you are trying to useDynamicResource
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
add a comment |
1 Answer
1
active
oldest
votes
<?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>
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'.
AndError 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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
<?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>
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'.
AndError 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
add a comment |
<?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>
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'.
AndError 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
add a comment |
<?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>
<?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>
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'.
AndError 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
add a comment |
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'.
AndError 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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