Adding a button to the title bar Xamarin Forms
Haven't been able to find quite the right answer for this yet. I want to add a button into the navigation / title bar at the top of a Xamarin Forms Navigation Page. Note that I need to know a method that will work on android, I'm not interested in trying to find an iOS only solution here. This button needs to be an image button as I want a way to access a hamburger menu.
Solution 1:
Use ToolbarItem
from YourPage.xaml.cs
:
ToolbarItems.Add(new ToolbarItem("Search", "search.png",() =>
{
//logic code goes here
}));
In Xaml:
<ContentPage.ToolbarItems>
<ToolbarItem Icon="search.png" Text="Search" Clicked="Search_Clicked"/>
</ContentPage.ToolbarItems>
Update
Xamarin.Forms introduced TitleView
in 3.2.0 that you can customize title of the navigation.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TestPage">
<NavigationPage.TitleView>
<Button ... />
</NavigationPage.TitleView>
...
</ContentPage>