I am trying to implement a loading/is busy logic in my app. When the item is selected from a collection view it shows a popup of a activity indicator which works fine. But, I am unable to close the popup once the other view loads. I have tried calling Close() but that doesnt do anything. So pretty much just trying to figure out the best way to show a activity indicator then close it once the process is done.
async void ItemSelected(object sender, SelectionChangedEventArgs e)
{
var popup = new LoadingPopup();
this.ShowPopup(popup);
var item = e.CurrentSelection.FirstOrDefault();
if (item != null)
{
await Navigation.PushAsync(new YearPage(item) {BindingContext = item });
//await Application.Current.MainPage.Navigation.PushAsync(new YearPage
//{
// BindingContext = item
//});
}
}
Calling close on the popup from a different view page(as the method doing the work is on a different page and I want to close the popup once it is done) doesnt work.
CodePudding user response:
you need to pass a reference to the popup to the 2nd page
var popup = new LoadingPopup();
this.ShowPopup(popup);
var item = e.CurrentSelection.FirstOrDefault();
if (item != null)
{
await Navigation.PushAsync(new YearPage(item, popup) {BindingContext = item });
then you would have to modify the YearPage
constructor to accept that 2nd parameter
then you would have a public method on LoadingPopup
to dismiss via the Close()
method