Let's say i have 3 Xaml views and i use a MasterDetailPage and NavigationPage to navigate back and forward to those pages. Page A -> Page B -> Page C -> ...
I use PushAsync to perform the navigation. No big deal...
I implemment that in two ways:
1 - Create a new instance of those views every time on navigation:
await Navigation.PushAsync(new Views.PageA());
2 - Create a static property (at App view) for each page and i use that for navigation:
public static Views.PageA PageA
{
get
{
if (_pageA == null)
{
_pageA = new Views.PageA();
}
return _pageA =;
}
}
await Navigation.PushAsync(App.PageA);
Is there another way to do that? Use static or new instance every time?
My concern it's about performance and memmory usage.
Please let's your answear with your opinion and some code will be apreciated.
Android
? – Ali BahramiiOS
andAndroid
but AndroidActivity
s will always get re-created. One of the workarounds isSingleton
– Ali Bahrami