Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

c# - Why Toolbar not showing on iOS display using Xamarin

I want to display very simple Toolbar using xamarin on iOS, but I can't see the toolbar on display.

I use this code:

    <?xml version="1.0" encoding="utf-8" ?>
      <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                   x:Class="Test.MainPage">

        <ContentPage.ToolbarItems>
          <ToolbarItem Text="Example Item"
                       IconImageSource="https://img.icons8.com/cute-clipart/64/000000/menu.png"
                     Order="Primary"
                     Priority="0" />
        </ContentPage.ToolbarItems>

</ContentPage>

There are no errors in the code and the display is empty..

What needs to change to see the toolbar ?

question from:https://stackoverflow.com/questions/65918746/why-toolbar-not-showing-on-ios-display-using-xamarin

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Are you putting your page in NavigationPage? By default ContentPage does not have Navigation bar (Toolbar), you must put your page in NavigationPage, after that Navigation bar will show up with its functionality. have a look at here : Xamarin.Forms Navigation

So I assume you should do something like this

public App ()
{
   MainPage = new NavigationPage (new MainPage());
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...