Adding Search Icon to Toolbar

Bubba Jones 206 Reputation points


I have been trying to insert a search control in a toolbar. I understand that in order to do this I need to write a custom renderer. I have based myself on the following:

With the complete solution found here:

I have integrated the relevant portions of the above solution into my project. However despite my best efforts have not been able to get the search icon to appear in my toolbar. My code is displayed below. When I debug the SearchPageRenderer.cs in the android project, OnElementChanged gets called which then calls AddSearchToToolbar. This behavior is correct. In AddSearchToToolbar all the if statements in it check out which is also correct. Still no search icon appears in the toolbar. Its been a week and i'm all out of ideas at this point.

If there are other more simple solutions to implementing this, i'm all ears. This has been my first (and very unpleasent) experience with custom renderers.

My relevant code is viewable in the attachment.

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,253 questions
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,931 Reputation points


    Welcome to our Microsoft Q&A platform!

    If there are other more simple solutions to implementing this

    To display a view in Navigation Bar, you could just use the NavigationPage.TitleView.

       <ContentPage ...>  
               <SearchBar />  

    Check the doc:

    Best Regards,

    Jarvan Zhang

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful