Subrata
Subrata

Reputation: 29

How to close a content page on button click and remove that from stack in xamarin forms?

want to close a content page on button click and remove it from stack,so how to achieve this.PopAsync is not working for me.

Upvotes: 0

Views: 12337

Answers (2)

Sallaam
Sallaam

Reputation: 63

you need to call

Application.Current.MainPage.Navigation.PopAsync();

from async void. for example if you have button click handler just add async keyword before void like this:

private async void Button_Clicked(object sender, EventArgs e)
   {

       await Application.Current.MainPage.Navigation.PopAsync();

   }

Upvotes: 0

Ricardo Romo
Ricardo Romo

Reputation: 1624

To remove some page of you navigation stack you can use.

this.Navigation.RemovePage (this.Navigation.NavigationStack [your page index]);

but if you just want to go back screen or go to main page of your navigation stack you can use this.

this.Navigation.PopAsync ();
this.Navigation.PopToRootAsync();

Upvotes: 1

Related Questions