我有一个带有三个选项卡的选项卡式页面,这是我的主页。在其中一个选项卡中,我有一个列表视图,单击列表视图中的项目后,我想导航到新页面。
我可以导航到新页面,但页面显示在选项卡中。我不希望该页面位于选项卡中,应该打开一个新页面,占据整个屏幕。
这是我的列表视图项目其中一个选项卡中的选定方法。
如何使 DocketDetail 页面占据整个屏幕。
我尝试使其成为"主页"
App.Current.MainPage = new NavigationPage(new DocketDetail());
但是这样做我无法回到选项卡页面。
请建议
lvLiveDockets.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
{
if (e.SelectedItem == null)
{
DisplayAlert("Item DeSelected", e.SelectedItem.ToString(), "Ok");
return; //ItemSelected is called on deselection, which results in SelectedItem being set to null
}
else
{
DisplayAlert("Item Selected", e.SelectedItem.ToString(), "Ok");
this.Navigation.PushAsync(new DocketDetail());
}
//((ListView)sender).SelectedItem = null; //uncomment line if you want to disable the visual selection state.
};
我的应用程序.cs
MainPage = new TabbedPage
{
Children =
{
new NavigationPage(new PendingDockets())
{
Title = "Pending Dockets",
Icon = Device.OnPlatform<string>("tab_about.png",null,null)
},
new NavigationPage(new LiveDockets())
{
Title = "Live Dockets",
Icon = Device.OnPlatform<string>("tab_about.png",null,null)
},
new NavigationPage(new ArchiveDockets())
{
Title = "Archive Dockets",
Icon = Device.OnPlatform<string>("tab_about.png",null,null)
},
}
};`
您的App.cs
可以更改为:
MainPage = new NavigationPage(new TabbedPage()
{
Children =
{
new PendingDockets()
{
Title = "Pending Dockets",
Icon = Device.OnPlatform<string>("tab_about.png",null,null)
},
new LiveDockets()
{
Title = "Live Dockets",
Icon = Device.OnPlatform<string>("tab_about.png",null,null)
},
new ArchiveDockets()
{
Title = "Archive Dockets",
Icon = Device.OnPlatform<string>("tab_about.png",null,null)
},
}
});
您必须将选项卡式页面放在导航堆栈中(我认为是根页面(
Application.Current.MainPage = new NavigationPage(new Tabpage());
当您在列表视图中选择您的项目时,您应该推送一个新页面
Navigation.PushAsync(new DocketDetail());
我希望了解您的问题
lvLiveDockets.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
{
if (e.SelectedItem == null)
{
DisplayAlert("Item DeSelected", e.SelectedItem.ToString(), "Ok");
return; //ItemSelected is called on deselection, which results in SelectedItem being set to null
}
else
{
DisplayAlert("Item Selected", e.SelectedItem.ToString(), "Ok");
Application.Current.MainPage = new DocketDetail();
}
//((ListView)sender).SelectedItem = null; //uncomment line if you want to disable the visual selection state.
};