I have two pages in a Xamarin Forms application, and I'm trying to do basic navigation:
public partial class Page1
{
void OnAddButtonClicked (object sender, EventArgs args)
{ Navigation.PushAsync (new Page2 ()); }
}
public partial class Page2
{
~Page2()
{ Debug.WriteLine ("Page2.~Page2()"); }
protected override void OnAppearing ()
{ Debug.WriteLine ("Page2.OnAppearing()"); }
protected override void OnDisappearing ()
{ Debug.WriteLine ("Page2.OnDisappearing()"); }
}
public class App : Application
{
public App()
{
MainPage = new NavigationPage(new Page1());
}
}
When I press the button, the second page appears as desired, and when I press the "Back" button (OS return button or left arrow in the title bar), it returns to the first page, but as for me, my second page never breaks . I understand that the garbage collector works whenever it is damn happy, but I can switch between pages several times (each time creating a new page) and sit without touching the application for several minutes, and none of the Page2 objects are ever destroyed .
, qaru.site/questions/90448/..., , . , - , Xamarin ?