Can't get FontSize for labels to work in ResourceDictionary when using OnPlatform
up vote
0
down vote
favorite
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 |
up vote
0
down vote
favorite
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 at 16:23
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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 at 13:06
Mattias 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 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 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 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 at 16:23
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
<?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 at 13:29
@MattiasGreger I modified my answer, you can check it.
– AbbyWang
Nov 28 at 2:48
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
<?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 at 13:29
@MattiasGreger I modified my answer, you can check it.
– AbbyWang
Nov 28 at 2:48
add a comment |
up vote
0
down vote
<?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 at 13:29
@MattiasGreger I modified my answer, you can check it.
– AbbyWang
Nov 28 at 2:48
add a comment |
up vote
0
down vote
up vote
0
down vote
<?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 at 2:46
answered Nov 22 at 7:07
AbbyWang
814
814
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 at 13:29
@MattiasGreger I modified my answer, you can check it.
– AbbyWang
Nov 28 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 at 13:29
@MattiasGreger I modified my answer, you can check it.
– AbbyWang
Nov 28 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 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 at 13:29
@MattiasGreger I modified my answer, you can check it.
– AbbyWang
Nov 28 at 2:48
@MattiasGreger I modified my answer, you can check it.
– AbbyWang
Nov 28 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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 at 16:23