在TabbedPage Xamarin中使用NavigationPage时图像消失

时间:2020-02-14 22:59:13

标签: c# xamarin.forms

我试图在选项卡式页面中创建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" }));

我的图标和标题消失了。我不知道如何解决

1 个答案:

答案 0 :(得分:0)

您应该在icon上添加titleNavigationPage

tabbedPage.Children.Add(new NavigationPage(new MainPage()) { Title = "myTabName", Icon = "Icon.png" });