Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Device.OnPlatform obsolete

paulharley421paulharley421 USMember ✭✭
edited August 2017 in Xamarin.Forms

How can I fix the warning about Device.OnPlatform obsolete? I know it was replace by using switch, but how can I fix Icon = Device.OnPlatform("tab_feed.png",null,null)

public static void SetMainPage()
{
    Current.MainPage = new TabbedPage
    {
        Children =
        {
            new NavigationPage(new ItemsPage())
            {
                Title = "Browse",
                Icon = Device.OnPlatform("tab_feed.png",null,null)
            },
            new NavigationPage(new AboutPage())
            {
                Title = "About",
                Icon = Device.OnPlatform("tab_about.png",null,null)
            },
        }
    };
}1. 

Best Answers

Answers

  • NMackayNMackay GBInsider, University admin
    edited August 2017

    @paulharley421

    You'd have to write your own extension method or use a case statement in that scenario, OnPlatform now is really more aimed at been XAML friendly. You'd be able to put that code into your XAML quite easily.

  • paulharley421paulharley421 USMember ✭✭

    @NMackay said:
    @paulharley421

    You'd have to write your own extension method or use a case statement in that scenario, OnPlatform now is really more aimed at been XAML friendly. You'd be able to put that code into your XAML quite easily.

    im really new to xamarin, can you provide an example to deal in for scenario?

Sign In or Register to comment.