Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a menu to a Xamarin.Forms ToolbarItem?

I am looking for a way to add a menu to my ToolbarItem. Right now its just clickable text, here is an example of what I am trying to create,

Menu on Toolbar

Here is what I have so far:

<ContentPage.ToolbarItems>
        <ToolbarItem Text="{Binding EditButtonText, Mode=TwoWay}" Clicked="EditClicked" />
    </ContentPage.ToolbarItems>
like image 520
Trevi Awater Avatar asked Sep 11 '15 12:09

Trevi Awater


People also ask

How to Add Toolbar Item in Xamarin Forms?

The Xamarin. Forms ToolbarItem class is a special type of button that can be added to a Page object's ToolbarItems collection. Each ToolbarItem object will appear as a button in the application's navigation bar. A ToolbarItem instance can have an icon and appear as a primary or secondary menu item.

What is Shell in Xamarin forms?

Xamarin. Forms Shell reduces the complexity of mobile application development by providing the fundamental features that most mobile applications require, including: A single place to describe the visual hierarchy of an application. A common navigation user experience.


1 Answers

You should be able to set the order of the ToolBarItem to Secondary to force the option into an overflow menu on Android:

<ContentPage.ToolbarItems>
        <ToolbarItem Text="{Binding EditButtonText, Mode=TwoWay}" Clicked="EditClicked" Order="Secondary" />
</ContentPage.ToolbarItems>

enter image description here

like image 56
pnavk Avatar answered Nov 09 '22 22:11

pnavk