Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Viewmodels not disposing on navigation.pop?

$
0
0

Hello

Ive ran into a problem where if i setup a page with a viewmodel using Xlabs ViewFactory... its not disposing on popasync?

The problem it causes for me is that the viewmodel subscribes to the message center.. and if i go down in my stack, only to come back up again.. i now have 2 viewmodels listening to the same event.. which is causing problems and concern.

To be more specific, when pushing a page... the popping it.. then pushing it again.. i now have 2 viewmodels listening to the same events.

Im not sure if something is wrong with my view factory tho.. this is how i use it:

ViewFactory.Register<LoginPage, LoginViewModel>();

And then i push pages like this:

Navigation.PushAsync((ContentPage)ViewFactory.CreatePage<LoginViewModel, LoginPage>());

And:

Navigation.PopAsync();

Am i doing something wrong or do i just need to stop all subscriptions before popping?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>