我试图在选项卡式页面中创建NavigationPage,首先,我在app.xaml.cs中使用了此代码
var tabbedPage = new Xamarin.Forms.TabbedPage();
tabbedPage.On<Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);
tabbedPage.BarBackgroundColor = Color.White;
tabbedPage.Children.Add(new MainPage() { Title = "myTabName", Icon = "Icon.png" });
tabbedPage.Children.Add(new MainPage() { Title = "myTabName", Icon = "Icon.png" });
tabbedPage.Children.Add(new MainPage() { Title = "myTabName", Icon = "Icon.png" });
tabbedPage.Children.Add(new MainPage() { Title = "myTabName", Icon = "Icon.png" });
tabbedPage.Children.Add(new MainPage() { Title = "myTabName", Icon = "Icon.png" });
MainPage = tabbedPage;
好的,它很完美。但是当我尝试使用它时-
tabbedPage.Children.Add(new NavigationPage(new MainPage() { Title = "myTabName", Icon = "Icon.png" }));
我的图标和标题消失了。我不知道如何解决
答案 0 :(得分:0)
您应该在icon
上添加title
和NavigationPage
:
tabbedPage.Children.Add(new NavigationPage(new MainPage()) { Title = "myTabName", Icon = "Icon.png" });