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 mod
    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.