Share via

Prism destroy not called when popping view

EJ 366 Reputation points
2021-08-03T02:38:03.637+00:00

Hi,

After 50% into the project I just realised that Prism for Xamarin Forms doesn't call Destroy method when popping view back. In my app MainPage is TabbedPage. So from TabbedPage in one of the tabs I push another view:

await navigationService.NavigateAsync("PageA", navigationParameters, false);

On PageA when I click on back arrow, page is removed from the stack, but Destroy method is not called in PageA view model. PageA implements IDestructible. Interestingly, if I use GoBackAsync method to close PageA then Destroy is called, so only using default back arrow doesn't work.

Anyone else has this issue? Not sure if this is a bug or by design? I need to cleanup in view model after it's being removed from the navigation stack.

Xamarin Forms: 5.0.0.2083
Prism: 7.2.0.1422

Developer technologies | .NET | Xamarin

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.