Rg.plugins.popup: Navigate to another page using PushAsync from ListView inside Popup

Created on 12 Aug 2016  路  5Comments  路  Source: rotorgames/Rg.Plugins.Popup

Hi, rotorgames. I wanna thank you first for this awesome plugin. But I've got a problem, tho.

So, my case is, i have ListView element inside my PopupPage, and I want to give the OnClick action of the list item so it can be navigate to another page which have to be one stack above the home page (main/root page of the popup). and when 'Back' button hit, the screen will switch back to the home/main page.

In PopupPage.xaml.cs, I implement this code for listItem.ItemSelected:

async void OnItemSelected(object sender, SelectedItemChangedEventArgs e){
      await Navigation.PushAsync(new FilterResultPage());
}

and I got this error when the function fired

System.InvalidOperationException: PushAsync is not supported globally on Android, please use a NavigationPage.

I think it might be has something to do with Navigation and NavigationPage stuff, I've tried some trick, But i still stuck.

Can you help me with this? Thank you so much

question

Most helpful comment

Thanks for your answer @rotorgames, I'm a bit overwhelmed because beside using NavigationPage, I also manage the page using MasterDetailPage, but finally it's all ok by tried this line:

await ((MainPage)App.Current.MainPage).Detail.Navigation.PushAsync(new FilterResultPage(1, 1));

Thank You.

All 5 comments

@widiarifki Hello friend. You need use NavigationPage.

MainPage = new NavigationPage(new YourPage());

Also you must close all PopupPage before call PushAsync

await Navigation.PopPopupAsync();
//or
Navigation.PopAllPopup();

Thanks for your answer @rotorgames, I'm a bit overwhelmed because beside using NavigationPage, I also manage the page using MasterDetailPage, but finally it's all ok by tried this line:

await ((MainPage)App.Current.MainPage).Detail.Navigation.PushAsync(new FilterResultPage(1, 1));

Thank You.

I have my app running in a MasterDetail page, so in my ViewModel I use @widiarifki line:

        await((MasterDetailPage1)App.Current.MainPage).Detail.Navigation.PushAsync(new ServicoLista());

Thank's @widiarifki that really helps

@widiarifki @mxdcarmo I am also trying to build same feature in my app. Will you guys help me with a bit of xaml code of yours for the popup where you guys are displaying listview.

I have BottomBar navigation using Shell. I able to Navigate, executing the following code:

await ((AppShell)App.Current.MainPage).CurrentItem.CurrentItem.Navigation.PushAsync(new AddTransactionsPage());

Thanks @rotorgames @widiarifki for the help

Was this page helpful?
0 / 5 - 0 ratings