title: Xamarin form ListView size (height) to content?
body: <p>I'm developing a mobile application and I want to put one Grid in the SrollView, under it a ListView with the height of its elements, under the ListView another ListView with same height. 
  I put two Listviews in StackLayout.  It should look something like that
  <a href="https://i.stack.imgur.com/oOSll.png" rel="nofollow noreferrer">This is content that should scroll in ScrollView </a></p>
  
  <p>But with this implementation(code below), the first ListView Occupies the entire remaining height, and the second Listview is far from it
  <a href="https://i.stack.imgur.com/8I5ei.png" rel="nofollow noreferrer">there is listview height at the full remaining size</a></p>
  
  <p>And my second Listview after scrolling is far away, here
  <a href="https://i.stack.imgur.com/OJvG9.png" rel="nofollow noreferrer">It also occupies the entire height of the scrollview</a></p>
  
  <p>Here is the code:</p>
  
  <pre><code> &lt;ScrollView&gt;
                  &lt;Grid RowSpacing="2"&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="130"/&gt;
                          &lt;RowDefinition Height="*" /&gt;
                      &lt;/Grid.RowDefinitions&gt;
  
                      &lt;Grid x:Name="RecommendedCaloriesGrid" Grid.Row="0"  RowSpacing="2" ColumnSpacing="1"
                            BackgroundColor="Violet" Margin="3"&gt;
  
  
                          // here is code of my Grid 1
                          &lt;/Grid&gt;
                      &lt;/Grid&gt;
  
                      &lt;StackLayout Grid.Row="1"&gt; // here I want to make a listview under Each other
                          &lt;ListView x:Name="ItemsListView" BackgroundColor="red"
                                  ItemsSource="{Binding Items}"
                                  HasUnevenRows="true"
                                  RefreshCommand="{Binding LoadItemsCommand}"
                                  IsPullToRefreshEnabled="true"
                                  IsRefreshing="{Binding IsBusy, Mode=OneWay}"
                                  CachingStrategy="RecycleElement"
                                  ItemSelected="OnItemSelected"&gt;
                              &lt;d:ListView.ItemsSource&gt;
                                  &lt;x:Array Type="{x:Type x:String}"&gt;
                                      &lt;x:String&gt;First Item&lt;/x:String&gt;
                                      &lt;x:String&gt;Second Item&lt;/x:String&gt;
                                  &lt;/x:Array&gt;
                              &lt;/d:ListView.ItemsSource&gt;
                              &lt;ListView.Header&gt;
                                  &lt;StackLayout Margin="5" Spacing="2"&gt;
                                      &lt;StackLayout Orientation="Horizontal"&gt;
                                          &lt;Label Text="Завтрак" HorizontalOptions="StartAndExpand"
                                                     FontSize="Large" FontAttributes="Bold"/&gt;
                                          &lt;Label Text="744 ккал" HorizontalOptions="EndAndExpand"
                                                     FontSize="Large" FontAttributes="Bold"/&gt;
                                      &lt;/StackLayout&gt;
                                      &lt;Label Text="Рекомендуется 30% от суточного потребления (n ккал)." FontSize="11"/&gt;
                                  &lt;/StackLayout&gt;
                              &lt;/ListView.Header&gt;
                              &lt;ListView.ItemTemplate&gt;
                                  &lt;DataTemplate&gt;
                                      &lt;ViewCell&gt;
                                          &lt;StackLayout Padding="10"&gt;
                                              &lt;Label Text="{Binding Text}" 
                              d:Text="{Binding .}"
                              LineBreakMode="NoWrap" 
                              Style="{DynamicResource ListItemTextStyle}" 
                              FontSize="16" /&gt;
                                              &lt;Label Text="{Binding Description}" 
                              d:Text="Item descripton"
                              LineBreakMode="NoWrap"
                              Style="{DynamicResource ListItemDetailTextStyle}"
                              FontSize="13" /&gt;
                                          &lt;/StackLayout&gt;
                                      &lt;/ViewCell&gt;
                                  &lt;/DataTemplate&gt;
                              &lt;/ListView.ItemTemplate&gt;
                          &lt;/ListView&gt;
                          &lt;ListView x:Name="LunchListView"           // second  ListView under first
                                  ItemsSource="{Binding Items}"
                                  HasUnevenRows="true"
                                  RefreshCommand="{Binding LoadItemsCommand}"
                                  IsPullToRefreshEnabled="true"
                                  IsRefreshing="{Binding IsBusy, Mode=OneWay}"
                                  CachingStrategy="RecycleElement"
                                  ItemSelected="OnItemSelected"&gt;
                              &lt;d:ListView.ItemsSource&gt;
                                  &lt;x:Array Type="{x:Type x:String}"&gt;
                                      &lt;x:String&gt;First Item&lt;/x:String&gt;
                                      &lt;x:String&gt;Second Item&lt;/x:String&gt;
                                      &lt;x:String&gt;Third Item&lt;/x:String&gt;
                                      &lt;x:String&gt;Forth Item&lt;/x:String&gt;
                                  &lt;/x:Array&gt;
                              &lt;/d:ListView.ItemsSource&gt;
                              // SAME logic here
  
                              &lt;/ListView.ItemTemplate&gt;
                          &lt;/ListView&gt;
                      &lt;/StackLayout&gt;
  
                  &lt;/Grid&gt;
              &lt;/ScrollView&gt;
  </code></pre>
  
  <p>How I can fix it? </p>
  
  <p>Please help me to find a solution.
  I read many articles like below, but did not find the answer. I want to do this without calculating the height in code-behind:</p>
  
  <p><a href="https://stackoverflow.com/questions/44655066/xamarin-forms-listview-size-to-content">Xamarin.Forms ListView size to content?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/38034194/xamarin-forms-listview-change-height-at-runtime">Xamarin.Forms - ListView change height at runtime</a></p>
  
  <p><a href="https://forums.xamarin.com/discussion/comment/66248" rel="nofollow noreferrer">https://forums.xamarin.com/discussion/comment/66248</a></p>
  
  <p><a href="https://stackoverflow.com/questions/24598261/xamarin-forms-listview-inside-stacklayout-how-to-set-height">Xamarin.Forms: ListView inside StackLayout: How to set height?</a></p>