1

I am try to add search bar in navigation bar in both Xamarin.android and Xamarin.Ios. I have tried the below post it's working ' but I want to customise the searchbar text color and search bar image in that. Can you please suggest any idea.

I am tried link : https://www.linkedin.com/pulse/xamarin-forms-contentpage-searchbar-navigation-bar-vipin-mathews

enter image description here

When I apply above link code I am getting navigation bar like this and when user click on search image, search bar will be appear in navigation bar. In the above navigation bar dot's image is a toolbar images set order is 'Primary'. My requirement is show search image first then after showing the toolbar image, exactly swap the position's of search image too bar image in the above image. How can I achieve that.

1
  • i've done the same tutorial than you but i have TWO problems. The first is that the cursos is not showing when i click on the SeachBar. and the MAIN one is that when i press back button to return to SearchPage, the navigationview is not there. Any suggestion? Apr 4, 2018 at 0:20

2 Answers 2

2

You use the Priority property of the ToolbarItem to define the left to right order, not the Ordering property. I know, not confusing at all!

<ContentPage.ToolbarItems>
    <ToolbarItem Name="SearchItem" Icon="search.png" Priority="0" />
    <ToolbarItem Name="MoreItem" Icon="more.png" Priority="1" />
</ContentPage.ToolbarItems>

Read this great blog post about the Xamarin Forms Toolbar for more details

2
  • Thanks steve, we are able to set toolbar item priorities like that but in above navigation bar search image is I am not added. due to adding search bar in navigation bar using custom renderer as fallow the above link I am getting. can you please suggest for this. If you open the above link you can get the clarity.
    – Deepak
    Oct 13, 2017 at 4:47
  • Looking at the link, the nav bar is all handled via custom Android code and renderers. The toolbar items are added in the XML near the top. I think you'll have to change this if you want to add a more button then update the renderer to grab the button like it does with the search button and wire it up to code in the PCL. Oct 13, 2017 at 4:53
0

Please use this library.

SNavigationPage

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:snav="clr-namespace:Stormlion.SNavigation;assembly=Stormlion.SNavigation"
             x:Class="Test.Page1"
             >
    <snav:SNavigationPage.NavContent>
        <Grid Margin="50, 0, 50, 0"
              >
            <SearchBar BackgroundColor="White"
                       Placeholder="Search ..."
                       />
        </Grid>
    </snav:SNavigationPage.NavContent>
    <ContentPage.Content>
        ...
    </ContentPage.Content>
</ContentPage>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.