title: Insert a cs stacklayout in a XAML stack layout
body: <p>I need for my application of insert a <code>searchplace</code> bar, but I have see a snippet only in C#, my application in that page already have a stack layout, and I can't insert all the two because if I run the application only the c# is rendered, someone can help me?</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
           xmlns:control="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView"
            xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
           x:Class="Sport.NewItemPage"
           Title="New Item"&gt;
  &lt;ContentPage.ToolbarItems&gt;
      &lt;ToolbarItem Text="Save" Clicked="Save_Clicked" /&gt;
  &lt;/ContentPage.ToolbarItems&gt;
  &lt;ContentPage.Content&gt;
     &lt;&lt;ScrollView&gt;
          &lt;StackLayout Spacing="15" Padding="15"&gt;
              &lt;StackLayout Orientation="Horizontal" &gt;
                  &lt;Label Text="Title" FontSize="Medium" /&gt;
                  &lt;Label x:Name="TipoPost" Text="Private" HorizontalOptions="EndAndExpand" /&gt;
                  &lt;Switch x:Name="Swi" Toggled="Switch_toggled" HorizontalOptions="End" /&gt;
              &lt;/StackLayout&gt;
              &lt;Entry Placeholder="Title" Text="{Binding Title}" FontSize="Small" /&gt;
              &lt;Button x:Name="DataButton"
                      Text="Select a date" 
                      FontSize="Medium"
                      BorderColor="White"
                      BackgroundColor="White"  
                      Clicked="Choose_date" /&gt;
              &lt;Label x:Name="DataCamp" HorizontalOptions="CenterAndExpand" FontSize="Medium"/&gt;
              &lt;StackLayout Orientation="Horizontal"&gt;
                  &lt;Image Source="clock.jpg" HorizontalOptions="Start" VerticalOptions="CenterAndExpand" HeightRequest="25"/&gt;
                  &lt;Label x:Name="orario" Text="Choose a time" HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand"/&gt;
                  &lt;TimePicker x:Name="Picker" HorizontalOptions="End" VerticalOptions="CenterAndExpand" PropertyChanged="Picker_PropertyChanged" /&gt;
              &lt;/StackLayout&gt;
              &lt;StackLayout Orientation="Horizontal"&gt;
                  &lt;SearchBar Placeholder="Search" SearchCommand="{Binding SearchCommand}" 
                             SearchCommandParameter="{Binding Path=Text,
                             RelativeSource={RelativeSource Self}}"/&gt;
                  &lt;Image Source="position.png" HorizontalOptions="Start" VerticalOptions="Center" HeightRequest="25"/&gt;
                  &lt;Entry x:Name="loc" Placeholder="Where is your event?" Text="{Binding Place}" FontSize="Medium" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand"/&gt;
  
  
              &lt;/StackLayout&gt;
              &lt;Label Text="Description" FontSize="Medium" /&gt;
              &lt;Entry x:Name="des" Placeholder="Enter a description" Text="{Binding Description}" FontSize="Medium" Margin="0"  /&gt;
              &lt;StackLayout Orientation="Horizontal"&gt;
                  &lt;Label Text="How many people can join this event?" FontSize="Medium" HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand"/&gt;
                  &lt;Button x:Name="MorePeople" Text="-" HeightRequest="25" WidthRequest="30" HorizontalOptions="EndAndExpand"/&gt;
                  &lt;Entry Keyboard="Numeric" Text="{Binding Participants}" Placeholder="People" HorizontalOptions="EndAndExpand" VerticalOptions="CenterAndExpand" /&gt;
                  &lt;Button x:Name="MinusPeople" Text="+" HeightRequest="25" WidthRequest="30" HorizontalOptions="EndAndExpand"/&gt;
  
              &lt;/StackLayout&gt;
          &lt;/StackLayout&gt;
      &lt;/ScrollView&gt;
  &lt;/ContentPage.Content&gt;
  </code></pre>
  
  <p></p>
  
  <p>and the C# is </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using Xamarin.Forms;
  using System.Collections.ObjectModel;
  using Xamarin.Forms.Maps;
  using Firebase.Xamarin.Database;
  using Firebase.Xamarin.Database.Query;
  using System.ComponentModel;
  using System.Threading.Tasks;
  using Newtonsoft.Json ;
  using System.Net.Http;
  using Sport.Services;
  //Xam.Plugin.Geolocator
  
  namespace Sport
  {
      public partial class NewItemPage : ContentPage
      {
          private const string API_KEY = "String";
  
          public Item Item { get; set; }
  
          public NewItemPage()
          {
              InitializeComponent();
              BindingContext = Item = new Item();
  
              var stack = new StackLayout();
              var search = new SearchBar();
             var listView = new ListView();
  
              stack = new StackLayout();
              search = new SearchBar();
              listView = new ListView();
  
              stack.Children.Add(search);
              stack.Children.Add(listView);   
  
  
              search.TextChanged += async (sender, e) =&gt;
              {
                  try
                  {
                      var searchBar = (SearchBar)sender;
                      var client = new HttpClient();
                      var url = "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=" + searchBar.Text + "&amp;types=geocode&amp;key=" + API_KEY;
  
                      var json = await client.GetStringAsync(url);
                      var predictionList = JsonConvert.DeserializeObject&lt;GooglePlaceResult&gt;(json);
                      var srcList = new List&lt;string&gt;();
  
                      foreach (var place in predictionList.predictions)
                      {
                          srcList.Add(place.description);
                      }
  
                      listView.ItemsSource = srcList;
                  }
                  catch (System.Exception)
                  {
                      await DisplayAlert("error", "unknown error", "ok");
                  }
              };
  
              Content = stack;
          }
          //metodi
  
          async void Save_Clicked(object sender, EventArgs e)
          {
              if (Item.Title == null || Item.Title.Equals("") || Item.Date == null)
              {
                  await DisplayAlert("Error", "You must insert a title and a date for your event", "Ok");
              }
              else
              {  
                  await DatabaseManager.DefaultManager.SaveTaskAsync(Item);
                  await DisplayAlert("Item saved", "You saved the item " + Item.Title, "Ok");
                  await Navigation.PopToRootAsync();
              }
          }
          async void Choose_date(object sender, EventArgs e)
          {
              await Navigation.PushModalAsync(new Pagine.CalendarPage(Item, DataCamp));
          }
  
          public void Switch_toggled()
          {
              if (Swi.IsToggled)
              {
                  TipoPost.Text = "Public";
                  Item.IsPublic = true;
              }
  
              else
              {
                  TipoPost.Text = "Private";
                  Item.IsPublic = false;
              }
          }
  
          private void Picker_PropertyChanged(object sender, PropertyChangedEventArgs e)
          {
              if (e.PropertyName.Equals("Time"))
                  Item.Time = Picker.Time.ToString();
          }
  
      }
  }
  </code></pre>