Xamarin.Forms Idiom adjustments


Example

Idiom specific adjustments can be done from C# code, for example for changing the layout orientation whether the view is shown or a phone or a tablet.

if (Device.Idiom == TargetIdiom.Phone) 
{
    this.panel.Orientation = StackOrientation.Vertical;
} 
else 
{
    this.panel.Orientation = StackOrientation.Horizontal;
}

Those functionalities are also available directly from XAML code :

<StackLayout x:Name="panel">
  <StackLayout.Orientation>
    <OnIdiom x:TypeArguments="StackOrientation">
      <OnIdiom.Phone>Vertical</OnIdiom.Phone>
      <OnIdiom.Tablet>Horizontal</OnIdiom.Tablet>
    </OnIdiom>
  </StackLayout.Orientation>
</StackLayout>