FreshMvvm
FreshMvvm copied to clipboard
ViewIsAppearing called multiple times
I have a very simple android application (targeting API level 23) built with Xamarin.Forms (2.4.0.282), FreshMvvm (2.2.0) with the following in the app.xaml.cs constructor:
var mainPage = FreshPageModelResolver.ResolvePageModel<MainPageModel>();
var mainNavContainer = new FreshNavigationContainer(mainPage);
MainPage = mainNavContainer;
The first time MainPageModel
is called/pushed, the ViewIsAppearing
method is called multiple times (normally twice, but I've seen 3 times). The ViewIsDisappearing
method is called almost immediately after each ViewIsAppearing
method is complete.
The ViewIsAppearing
method can simply have var x = 1;
in it and it would be called multiple times. I have nothing in the ViewIsDisappearing
but did override it just to see when it was getting called.
Is this a bug with FreshMVVM or Xamain? Or is there something else I should be looking at in my code?
Thanks, Mark Erickson
maybe you can share your code with us. I didnt experience such behavior.
I am also encounter this behaviour in my app. I am using FreshMvvm version 2.2.3.
same problem here
Do you mean that it appears 2 because once it is in the viewmodel ViewIsAppearing and 2nd in xaml.cs OnAppearing. this is the only 2 times I observed.
well , the first time the page loaded the ViewIsAppearing method is called 3 times , then its called 2 times everytime the page is loaded
I am also experiencing the same problem. Its causing a little bit of an issue for me.
@Ruddy2007 : I use FreshMvvm very regularly and have build a few apps with it. Never had this issue. I suspect it might be implemenation error. Can you please upload a sample project. I can review and get back to you soon.
@libin85 Sorry for the late reply, I will try to get round to creating a sample project and get back to you. :)
ViewIsAppearing might be called several times if your are calling OnAppearing() on your ContentPage.
Might be releaed to an issue I opened a little while ago on the Xamarin Forms Github page https://github.com/xamarin/Xamarin.Forms/issues/2240 which is a bug with Xamarin Forms
@libin85 Did you ever get anywhere with this?