title: Set Listview height based on the number of items in Xamarin Forms
body: <p>I have a <code>ListView</code> that shows suggestions. How can I set the <code>Height</code> of my list view based on the number of items? </p>
  
  <p>The maximum number of items is 10 and the minimum is 1.</p>
  
  <p>I have added a height request code base on the number of results still not working</p>
  
  <p>My XAML:</p>
  
  <pre><code>&lt;Label Text="RETAILER NAME" StyleClass="lbl-fieldform"/&gt;
                  &lt;Entry x:Name="NameSearch" StyleClass="fieldForm" Focused="NameSearch_Focused" Unfocused="NameSearch_Unfocused" TextChanged="NameSearch_TextChanged"/&gt;
                  &lt;ListView x:Name="lstName" IsVisible="False" HeightRequest="50" ItemTapped="lstName_ItemTapped"&gt;
                      &lt;ListView.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;ViewCell&gt;
                                  &lt;StackLayout StyleClass="lstContainer"&gt;
                                      &lt;Label StyleClass="lstName" Text="{Binding FileAs}"/&gt;
                                  &lt;/StackLayout&gt;
                              &lt;/ViewCell&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ListView.ItemTemplate&gt;
                  &lt;/ListView&gt;
                  &lt;Label Text="RETAILER CODE" StyleClass="lbl-fieldform"/&gt;
                  &lt;Picker Title="Select Retailer Code" x:Name="codePicker" ItemsSource="{Binding RetailerCode}" ItemDisplayBinding="{Binding RetailerCode}" StyleClass="fieldForm" IsEnabled="False"/&gt;
                  &lt;Label Text="STREET" StyleClass="lbl-fieldform"/&gt;
                  &lt;Entry IsEnabled="false" StyleClass="fieldForm" x:Name="entStreet"/&gt;
  </code></pre>
  
  <p>My formula for the height:</p>
  
  <pre><code>var db = DependencyService.Get&lt;ISQLiteDB&gt;();
  var conn = db.GetConnection();
  
  string sql = "SELECT * FROM tblContacts WHERE FileAs LIKE '%" + keyword + "%' ORDER BY FileAs LIMIT 10";
  var getUser = conn.QueryAsync&lt;ContactsTable&gt;(sql);
  var resultCount = getUser.Result.Count;
  
  if (resultCount &gt; 0)
  {
      var result = getUser.Result;
      lstName.HeightRequest = (resultCount * 50) + (10 * resultCount);
      lstName.ItemsSource = result;
  }
  else
  {
      lstName.IsVisible = false;
  }
  </code></pre>