Xamarin.Forms Platform adjustments


Example

Adjustments can be done for specific platforms from C# code, for example for changing padding for all the targeted platforms.

if (Device.OS == TargetPlatform.iOS) 
{
    panel.Padding = new Thickness (10);
}
else
{
    panel.Padding = new Thickness (20);
}

An helper method is also available for shortened C# declarations :

panel.Padding = new Thickness (Device.OnPlatform(10,20,0));

Those functionalities are also available directly from XAML code :

<StackLayout x:Name="panel">
  <StackLayout.Padding>
    <OnPlatform x:TypeArguments="Thickness"
      iOS="10"
      Android="20" />
  </StackLayout.Padding>
</StackLayout>