OnIdiom in Xaml for HorizontalOptions and VerticalOptions

This took a while to figure out as there seems to be no docs on how to do it. Finally managed to get horizontal or vertical options to differ depending on the device idiom e.g. phone or tablet.

 

   <StackLayout Orientation=”Horizontal” VerticalOptions=”FillAndExpand” Grid.ColumnSpan=”{Binding PropertyListGridSpan}” >
                                        <StackLayout.HorizontalOptions>
                                            <OnIdiom x:TypeArguments=”LayoutOptions”>
                                                <OnIdiom.Phone>LayoutOptions.Center</OnIdiom.Phone>
                                                <OnIdiom.Tablet>LayoutOptions.Start</OnIdiom.Tablet>
                                            </OnIdiom>
                                        </StackLayout.HorizontalOptions>
                                           

                                       

 Hope this helps someone out

Written by: agileadmin Posted on: 13th March 2017