Search code examples
c#popupmauicollectionview

Mopup on Maui - after popup call OnAppearing


I have a collectionview, and when you click on the collectionview item it opens up my mopup popup displaying that data. That works fine. When I click my delete button on the popup to delete that collectionview item my handler deletes and dismisses the popup but I need to figure out how to call OnAppearing on the initial class with the collectionview so that the source for the collectionview gets updated.

I know there is the BackgroundClicked event handler but that is not able to call OnAppearing in another class.

I am currently not using MVVM and not very good at it. Hoping there is an easy way to achieve this.

Edit:

private async void DeleteItem_Clicked(object sender, EventArgs e)
{
    
    var result = await DisplayAlert("Delete", $"Delete {Item.Name} from the database", "Yes", "No");
    if (result)
    {
        await App.Database.DeleteItem(item);
        await MopupService.Instance.PopAsync();
    }
    
}

Item is the object passed in to the popup that I want to delete via popup menu then update my collectionview on the base class where the popup was launched from initially.


Solution

  • I used the messagingcenter to subscribe to my popup page from my mainpage, then sent the item back I wanted to delete in my ObservableCollection through messagingcenter.send.