Reputation: 384
How to completely dispose Xamarin Forms Pages, their child views and respective data bindings ?
Upvotes: 4
Views: 3182
Reputation: 12723
About disposing Xamarin Forms Pages ,if using NavigationPage as root page in xamarin forms project .There is an easy way to close the page.
The NavigationPage class provides a hierarchical navigation experience where the user is able to navigate through pages, forwards and backwards, as desired. The class implements navigation as a last-in, first-out (LIFO) stack of Page objects.
To move from one page to another, an application will push a new page onto the navigation stack, where it will become the active page, as shown in the following diagram:
To return back to the previous page, the application will pop the current page from the navigation stack, and the new topmost page becomes the active page, as shown in the following diagram:
Navigation methods are exposed by the Navigation property on any Page derived types. These methods provide the ability to push pages onto the navigation stack, to pop pages from the navigation stack, and to perform stack manipulation.
their child views and respective data bindings
If need to deal with their child views and respective data bindings , you know that there is Page notification events can deal with that .
This event can be used in scenarios where you want to track pages as they appear on screen.
protected override void OnDisappearing()
{
base.OnDisappearing();
// deal with view modle or child views here
}
Upvotes: 4