sid
sid

Reputation: 157

How to take click on action bar icon in xamarin.forms?

I added the Notification icon on action bar. I want to take clicked on it. So how can i do this? Anyone knows please revert back with answer.

Upvotes: 1

Views: 2265

Answers (1)

cvanbeek
cvanbeek

Reputation: 1961

If you added a toolbar item you can do it like this:

ToolbarItems.Add(new ToolbarItem("Action Name", "Icon.png", async () =>
{
    //Your code on clicked
}));

To do it in Xaml, you need to add the command attribute:

<ContentPage.ToolbarItems>
    <ToolbarItem Name="Invite" Command="{Binding ToolbarItemCommand}"></ToolbarItem>
</ContentPage.ToolbarItems>

Then in your code behind define an ICommand named ToolbarItemCommand which will be triggered when the icon is clicked

Upvotes: 2

Related Questions