Hon*_*ála 4 c# events page-lifecycle xamarin xamarin.forms
我正在寻找类似函数的东西
protected override void OnDisappearing()
{
}
Run Code Online (Sandbox Code Playgroud)
在 Xamarin 表单中。问题是,即使我关闭手机显示屏,也会调用此功能。我正在寻找一种仅在页面更改时响应事件的功能 - 例如,菜单中的用户单击正在访问的页面以外的页面。
谢谢你的建议
你需要结合OnBackButtonPressed和OnDisappearing
或 OnAppearing和OnDisappearing
您可以创建一个base实现OnBackButtonPressedand orOnDisappearing和 or的页面OnAppearing。
然后将“活动”页面引用保存在静态变量中。
// this condition can help you concerning the screen on or off
if(this.Title == Activepage.Title) // or id
return;
Run Code Online (Sandbox Code Playgroud)