title: Layout issues trying to get ListView to show fixed number of items
body: <p>In a UWP Project I have a <code>ListView</code> that is bound to an <code>ObservableCollection&lt;T&gt;</code> of <code>Person</code> objects. I use a <code>DataTemplate</code> to display the <code>Person</code> object within the <code>ListView</code>. The collection (people) can only contain up to a certain number of people set by <code>_maxPeopleCount</code>.</p>
  
  <p>What I would like to happen is for the <code>ListView</code> to:</p>
  
  <ol>
  <li>Not scroll at all.</li>
  <li>Show ALL <code>Person</code> objects as defined by <code>_maxPeopleCount</code>.</li>
  <li>Show each <code>Person</code> objects fully, not partially. That is, show each item so that ListViewItem.Height = (Available Height from ItemsPanel ) / <code>_maxPeopleCount</code>.</li>
  <li>When there are less than <code>_maxPeopleCount</code> items to start with still show the added items with there Height as defined in (3).</li>
  <li>Show the FirstName and LastName of each Person to be as large as possible.</li>
  </ol>
  
  <p>At the moment I can't get my project to do this. </p>
  
  <p>Here is the example code that shows the issue. Simply press the button more than 7 times, as this is the <code>_maxPeopleCount</code> in the code. You will see that 7 people do not get shown. Apologies for the awful UI. It's made to show problem with minimal XAML but be similar to my real project.</p>
  
  <p>Code behind:</p>
  
  <pre><code>public sealed partial class MainPage : Page
  {
      ObservableCollection&lt;Person&gt; _people = new ObservableCollection&lt;Person&gt;();
      int _personCount = 0;
      int _maxPeopleCount = 7;
      public MainPage()
      {
          this.InitializeComponent();
          this.DataContext = _people;
  
      }
  
      private void btnAddPerson_Click(object sender, RoutedEventArgs e)
      {
          if (_people.Count == _maxPeopleCount)
          {
              _people.RemoveAt(_people.Count - 1);
          }
          _personCount += 1;
          _people.Insert(0, new Person($"FirstName {_personCount}", $"LastName {_personCount}"));
      }
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="*"/&gt;
          &lt;ColumnDefinition Width="*"/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
  
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="*"/&gt;
          &lt;RowDefinition Height="*"/&gt;
      &lt;/Grid.RowDefinitions&gt;
  
      &lt;Button Grid.Row="0" Grid.Column="0" x:Name="btnAddPerson" Click="btnAddPerson_Click" Content="Add Person" VerticalAlignment="Center" HorizontalAlignment="Center"/&gt;
  
      &lt;ListView BorderBrush="Black"  BorderThickness="5" Margin="10" Grid.Row="1" Grid.Column="0" ItemsSource="{Binding}" ScrollViewer.VerticalScrollMode="Disabled" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollMode="Disabled" VerticalAlignment="Stretch"  VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"&gt;
          &lt;ListView.ItemContainerStyle&gt;
              &lt;Style TargetType="ListViewItem"&gt;
                  &lt;Setter Property="HorizontalContentAlignment" Value="Stretch"/&gt;
              &lt;/Style&gt;
          &lt;/ListView.ItemContainerStyle&gt;
          &lt;ListView.ItemsPanel&gt;
              &lt;ItemsPanelTemplate&gt;
                  &lt;ItemsStackPanel HorizontalAlignment="Stretch"/&gt;
              &lt;/ItemsPanelTemplate&gt;
          &lt;/ListView.ItemsPanel&gt;
          &lt;ListView.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;Grid x:Name="grdPerson"&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="*"/&gt;
                          &lt;ColumnDefinition Width="*"/&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;Border Grid.Column="0" Background="Green" HorizontalAlignment="Stretch"&gt;
                          &lt;Viewbox&gt;
                              &lt;TextBlock Text="{Binding FirstName}" HorizontalAlignment="Stretch"/&gt;
                          &lt;/Viewbox&gt;
                      &lt;/Border&gt;
                      &lt;Border Grid.Column="1" Background="Yellow" HorizontalAlignment="Stretch"&gt;
                          &lt;Viewbox&gt;
                              &lt;TextBlock Text="{Binding LastName}" HorizontalAlignment="Stretch" /&gt;
                          &lt;/Viewbox&gt;
                      &lt;/Border&gt;
                  &lt;/Grid&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListView.ItemTemplate&gt;
      &lt;/ListView&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>PERSON CLASS:</p>
  
  <pre><code>  public class Person : INotifyPropertyChanged
  {
  
      public Person(string firstName, string lastName)
      {
           FirstName = firstName;
          LastName = lastName;
      }
  
  
      private string _firstName = string.Empty;
      public string FirstName
      {
          get { return _firstName; }
          set
          {
              _firstName = value;
              OnPropertyChanged();
          }
      }
  
  
      private string _lastName = string.Empty;
      public string LastName
      {
          get { return _lastName; }
          set
          {
              _lastName = value;
              OnPropertyChanged();
          }
      }
  
      protected void OnPropertyChanged([CallerMemberName] string caller = "")
      {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(caller));
      }
  
      public event PropertyChangedEventHandler PropertyChanged;
  
  
  }
  </code></pre>