Hrodlfr
Hrodlfr

Reputation: 41

What is the best way to place a SearchBar inside of your NavigationBar?

What is the best way to place a SearchBar inside of your NavigationBar for an android app?

Upvotes: 0

Views: 47

Answers (1)

Jarvan Zhang
Jarvan Zhang

Reputation: 1013

What is the best way to place a SearchBar inside of your NavigationBar?

The TitleView could help you display the SearchBar in the navigation bar easily.

Check the code:

<ContentPage ...>
    <NavigationPage.TitleView>
        <<SearchBar Text="testing for search bar"/>
    </NavigationPage.TitleView>
    ...
</ContentPage>

Update:

Page.xaml

<local:CustomPage 
    ...
    xmlns:local="clr-namespace:App19F_5"
    x:Class="App19F_5.Page6">

    ...
</local:CustomPage>

Page.xaml.cs

public partial class Page6 : CustomPage
{
    ...
}

CustomPage.xaml

<ContentPage ... x:Class="App19F_5.CustomPage">
    <NavigationPage.TitleView>
        <SearchBar />
    </NavigationPage.TitleView>
</ContentPage>

Upvotes: 1

Related Questions