[英]Xamarin Forms: How to show a full screen page when selecting a specific tab
I have a tabbed main application with Xamarin Forms. 我有一个Xamarin Forms的选项卡式主应用程序。
I am looking to open a Content page in full screen (without tabs and titles) when switching to a specific tab. 切换到特定标签时,我希望以全屏方式打开“内容”页面(不包含标签和标题)。 I am able to obtain the desired behaviour when I press a button like this: 当我按下这样的按钮时,我能够获得所需的行为:
await Navigation.PushModalAsync(new DashboardPage());
Though i'm not sure how to make it to automatically open when switching to that specific tab. 虽然我不确定切换到该特定选项卡时如何使其自动打开。
Any help will be so much appreciated, 任何帮助将不胜感激,
Thanks! 谢谢!
I managed to obtain it by adding the following to the tab page class: 我设法通过将以下内容添加到选项卡页面类中来获得它:
protected override void OnAppearing()
{
base.OnAppearing();
Navigation.PushModalAsync(new DashboardPage());
}
protected override void OnDisappearing()
{
base.OnDisappearing();
// move on a different tab to avoid infinite loop when back button is pressed
var masterPage = this.Parent as TabbedPage;
masterPage.CurrentPage = masterPage.Children[0];
}
Probably not the most elegant way but it does the job 可能不是最优雅的方式,但确实可以做到
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.