Xamarin.Forms - Label FontSize OnPlatform - XAML error

Viewed 6934

I have this code:

  <Label x:Name="questionGroupHintInfoLabel" FontAttributes="Bold"  Text="Folgende Hinweismeldung wurde für die aktuelle Fragengruppe hinterlegt:">
      <Label.FontSize>
        <OnPlatform x:TypeArguments="NamedSize"
                    iOS="Small"
                    Android="Small" />
      </Label.FontSize>
    </Label>

...and get this error:

No property, bindable property, or event found for FontSize

What i'm doing wrong?

Thanks.

3 Answers

old thread, but i was close to implement item 3 from answer above, when i find this syntax

<Style TargetType="Button" x:Key="ListButtonStyle">
       <Setter Property="FontSize" Value="{OnIdiom Phone={OnPlatform Android=Header, iOS=Micro} , Tablet=Large, Desktop=Default}" />
</Style>

checked it with phones with ios and android and it is working nicely . decided to leave it here. xamarin.forms 4.8.0.1687

You should try the new XAML for OnPlatform:

<!--Old XAML On Platform-->
<StackLayout>
  <StackLayout.Padding>
    <OnPlatform x:TypeArguments="Thickness" 
                Android="0, 0, 0, 0" 
                WinPhone="0, 0, 0, 0" 
                iOS="0, 20, 0, 0"/>
  </StackLayout.Padding>
</StackLayout>

<!--New XAML On Platform-->
<StackLayout>
  <StackLayout.Padding>
   <OnPlatform x:TypeArguments="Thickness">
     <On Platform="Android" Value="0, 0, 0, 0"/>
     <On Platform="WinPhone" Value="0, 0, 0, 0"/>
     <On Platform="iOS" Value="0, 20, 0, 0"/>
    </OnPlatform>
  </StackLayout.Padding>
</StackLayout>

<!--Better new XAML On Platform-->
<StackLayout>
  <StackLayout.Padding>
   <OnPlatform x:TypeArguments="Thickness">
     <On Platform="Android, WinPhone">0</On>
     <On Platform="iOS">0,20,0,0</On>
    </OnPlatform>
  </StackLayout.Padding>
</StackLayout>
Related