GreenKn1ght
GreenKn1ght
This is a critical bug in Xamarin.Android due to the fact that Page.OnAppearing is called every time the page appears on the phone screen: this **may** be caused by navigation...
@okunevdm did you use the UserControlLogic.CloseViewModelOnUnloaded property or came up with another solution?
I solved this by overriding the [OnParentSet](https://docs.microsoft.com/ru-ru/dotnet/api/xamarin.forms.page.onparentset?view=xamarin-forms#Xamarin_Forms_Page_OnParentSet) method and firing Loaded and Unloaded events depending on whether the [Parent](https://docs.microsoft.com/ru-ru/dotnet/api/xamarin.forms.element.parent?view=xamarin-forms#Xamarin_Forms_Element_Parent) is null. But before creating PR I need to test it...
By the way, we still want to know when the view appears or disappears in associated view model. Any thoughts? Can we extend ViewModelBase with OnAppearing and OnDisappearing methods?
> I solved this by overriding the [OnParentSet](https://docs.microsoft.com/ru-ru/dotnet/api/xamarin.forms.page.onparentset?view=xamarin-forms#Xamarin_Forms_Page_OnParentSet) method and firing Loaded and Unloaded events depending on whether the [Parent](https://docs.microsoft.com/ru-ru/dotnet/api/xamarin.forms.element.parent?view=xamarin-forms#Xamarin_Forms_Element_Parent) is null. > But before creating PR I need to...
I'll prepare sample to show this behavior.
Probably I'm blind, but there is only one difference: CustomBackButtonAction. I do not see how this changes the current behavior.
Please take a look at my [sample](https://github.com/GreenKn1ght/Catel.Xamarin.Forms.Todo).
Thus you prevent navigation. We should make it work out of the box, but initial issue is "After navigate to new page previous ViewModel is closing". How did you fix...
But if you navigate forward, your view model will still be closed and then recreated.