Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

How to use platform Idiom in Xaml

$
0
0

Although I can do the following in code, I want to do it in Xaml:

            if (Xamarin.Forms.Device.Idiom == TargetIdiom.Phone)
            {
                MainPage = new NavigationPage(new MyPage());
            }
            else if(Xamarin.Forms.Device.Idiom == TargetIdiom.Tablet)
            {
        // etc
            }
            else if(Xamarin.Forms.Device.Idiom == TargetIdiom.Desktop)
            {
        // etc
            }
            else if (Xamarin.Forms.Device.Idiom == TargetIdiom.Unsupported)
            {
                // etc
            }
            else
            {
                // etc
            }

Another post suggests the following, however it throws an error "OnIdiom" not found in xmlns: http://xamarin.com/schemas/2014/forms:

<StackLayout>
    <StackLayout.Orientation>
    <OnIdiom x:TypeArguments="StackOrientation">
        <OnIdiom.Phone>Vertical</OnIdiom.Phone>
        <OnIdiom.Tablet>Horizontal</OnIdiom.Tablet>
    </OnIdiom>
    </StackLayout.Orientation>
    <Label Text="child0"/>
    <Label Text="child1"/>          
</StackLayout>

Any ideas as to how to do this in Xaml?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>