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

New page Instance when navigating

$
0
0

I currently use MVVMLight for my Xamarin Forms project (fantastic library btw). And when you go to NavigateTo another page the example code they get you to push into the helper means that for every PushAsync it constructs a new Page. The ViewModels are of course static.

Is there any issue or preference as to why when a page is constructed it isn't stored in a list, so that you don't have to construct a new one when you go back to that page, just take it off the list.

This way it prevents any possible memory leaks if you forget to remove some code that keeps it referenced and I always made sure my page was loaded correctly with the OnAppearing rather than the constructor just to take that part out of the equation. Otherwise when you did a Pop you had to look for OnAppearing but in a Push you could use the constructor. Hence I just abandoned doing anything in the constructor anyway, except initial binding.

I am just opening this open to discussion or any opinions. Because in my books it speeds up my app immensely and saves many event handler issues from appearing, e.g. when I am tapping into the OnBackButtonPressed event.

But am I ignoring some pattern, or causing an issue I have yet to see?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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