Dynamic method for opening screens

Asked

Viewed 116 times

0

I am creating a method to open any screen I pass in the parameter.

I did this method:

public async Task NavigateTo(Page page)
{
    await App.MasterDetail.Detail.Navigation.PushAsync(new page());    
}

But every time I compile from one mistake

CS0118  "page" é um variável, mas é usado como um tipo

What you have to do to make it work?

  • instead of putting a new page, I think you should just put the page, which is being sent in the parameter. In my view, this way you will be starting a page that doesn’t even exist.

  • 1

    All right @Samuel, I’m gonna try this to see what

1 answer

1


Try to change that:

public async Task NavigateTo(Page page)
{
    await App.MasterDetail.Detail.Navigation.PushAsync(new page());    
}

To:

public async Task NavigateTo(Page page)
{
    await App.MasterDetail.Detail.Navigation.PushAsync(page);    
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.