title: How to add a SearchBar to the top of every page with Xamarin.Forms
body: <p>I'm new to Xamarin/Visual Studio For Mac(Preview). I'm not new to C#. Im struggling with how to get a SearchBar in the header.</p>
  
  <p>Im using the Xamarin.CRM Sample from the Xamarin Website.</p>
  
  <p>It looks like theres a ViewModel that is binding the title to the header of each page but I would rather have a search bar.</p>
  
  <p><b>XAML</b></p>
  
  <pre><code>&lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Phoodie.AboutPage" xmlns:vm="clr-namespace:Phoodie;" Title="{Binding Title}"&gt;
  &lt;ContentPage.BindingContext&gt;
      &lt;vm:AboutViewModel /&gt;
  &lt;/ContentPage.BindingContext&gt;
  </code></pre>
  
  <p><b>Code Behind</b></p>
  
  <pre><code>public partial class ItemsPage : ContentPage
  {
      ItemsViewModel viewModel;
  
      public ItemsPage()
      {
          InitializeComponent();
  
          BindingContext = viewModel = new ItemsViewModel();
      }
  
      async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
      {
          var item = args.SelectedItem as Item;
          if (item == null)
              return;
  
          await Navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(item)));
  
          // Manually deselect item
          ItemsListView.SelectedItem = null;
      }
  
      async void AddItem_Clicked(object sender, EventArgs e)
      {
          await Navigation.PushAsync(new NewItemPage());
      }
  
      protected override void OnAppearing()
      {
          base.OnAppearing();
  
          if (viewModel.Items.Count == 0)
              viewModel.LoadItemsCommand.Execute(null);
      }
  }
  </code></pre>
  
  <p><b>ViewModel</b></p>
  
  <pre><code>public ItemsViewModel()
      {
          Title = "Browse";
          Items = new ObservableRangeCollection&lt;Item&gt;();
          LoadItemsCommand = new Command(async () =&gt; await ExecuteLoadItemsCommand());
  
          MessagingCenter.Subscribe&lt;NewItemPage, Item&gt;(this, "AddItem", async (obj, item) =&gt;
          {
              var _item = item as Item;
              Items.Add(_item);
              await DataStore.AddItemAsync(_item);
          });
      }
  </code></pre>
  
  <p><b>What I'm trying to accomplish</b></p>
  
  <p><a href="https://i.stack.imgur.com/cOm2o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cOm2o.png" alt="enter image description here"></a></p>
  
  <p>THANK YOU FOR YOUR HELP AHEAD OF TIME!</p>