FreshMvvm icon indicating copy to clipboard operation
FreshMvvm copied to clipboard

ViewIsAppearing called multiple times

Open mwerickson opened this issue 7 years ago • 11 comments

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

mwerickson avatar Oct 12 '17 14:10 mwerickson

maybe you can share your code with us. I didnt experience such behavior.

EmilAlipiev avatar Oct 16 '17 09:10 EmilAlipiev

I am also encounter this behaviour in my app. I am using FreshMvvm version 2.2.3.

sjorsmiltenburg avatar Dec 25 '17 19:12 sjorsmiltenburg

same problem here

maherzaidoune avatar May 09 '18 08:05 maherzaidoune

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.

EmilAlipiev avatar May 09 '18 10:05 EmilAlipiev

well , the first time the page loaded the ViewIsAppearing method is called 3 times , then its called 2 times everytime the page is loaded

maherzaidoune avatar May 09 '18 10:05 maherzaidoune

I am also experiencing the same problem. Its causing a little bit of an issue for me.

RuddyOne avatar Feb 06 '19 09:02 RuddyOne

@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 avatar Feb 06 '19 10:02 libin85

@libin85 Sorry for the late reply, I will try to get round to creating a sample project and get back to you. :)

RuddyOne avatar Feb 12 '19 15:02 RuddyOne

ViewIsAppearing might be called several times if your are calling OnAppearing() on your ContentPage.

kwabenaowusujnr avatar Feb 26 '19 08:02 kwabenaowusujnr

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

LeoJHarris avatar Jul 09 '19 21:07 LeoJHarris

@libin85 Did you ever get anywhere with this?

gazwinter avatar Oct 08 '19 10:10 gazwinter