I'm looking for something like a function
protected override void OnDisappearing()
{
}
in Xamarin Forms. The problem is that this feature is called even when I turn off the phone display. I'm looking for a feature that only responds to the event when the page is changed - for example, the user in the menu clicks on a page other than the one that is being visited.
thanks for your advice
You will need to combine OnBackButtonPressed and OnDisappearing
OR OnAppearing and OnDisappearing
You can create a base page which implement OnBackButtonPressed and or OnDisappearing and or OnAppearing.
And you save "Active" page reference in a static variable.
// this condition can help you concerning the screen on or off
if(this.Title == Activepage.Title) // or id
return;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With