title: How to enable scrolling in Expander without a fixed height
body: <p>I'm having problems with scrolling inside the <a href="https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/expander" rel="nofollow noreferrer">Expander control</a>. Since the default behaviour of the Expander is to grow to fit all content, scrolling doesn't work for any child controls as there's no height limit.</p>
  
  <p>Here's a layout I'm trying to make work. I want the Expanders to stretch to the window's height, not over it, and the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.listview" rel="nofollow noreferrer">ListView</a> inside the first Expander should be scrollable.</p>
  
  <p><a href="https://i.stack.imgur.com/IxqaO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IxqaO.png" alt="enter image description here"></a></p>
  
  <p>I can get it to work if I set a fixed height on the Expander (like in <a href="https://stackoverflow.com/questions/32648912/scrollviewer-in-expander">this answer</a>), but as the app window should be resizable, fixed height isn't a solution.</p>
  
  <p>What can I do?</p>
  
  <pre><code>&lt;Page.Resources&gt;
    &lt;Style TargetType="my:Expander"&gt;
      &lt;Setter Property="ExpandDirection" Value="Right"/&gt;
      &lt;Setter Property="VerticalContentAlignment" Value="Stretch"/&gt;
    &lt;/Style&gt;
    &lt;Style TargetType="ListView" x:Key="ListStyle"&gt;
      &lt;Setter Property="Width" Value="350"/&gt;
      &lt;Setter Property="Padding" Value="10"/&gt;
      &lt;Setter Property="BorderBrush" Value="Gray"/&gt;
      &lt;Setter Property="BorderThickness" Value="0,0,1,0"/&gt;
    &lt;/Style&gt;
  &lt;/Page.Resources&gt;
  
  &lt;my:MasterDetailsView ItemsSource="{x:Bind Models}" 
                        HorizontalAlignment="Stretch" 
                        VerticalAlignment="Stretch"&gt;
    &lt;my:MasterDetailsView.ItemTemplate&gt;
      &lt;DataTemplate x:DataType="local:Model"&gt;
        &lt;TextBlock Text="{x:Bind Title}"/&gt;
      &lt;/DataTemplate&gt;
    &lt;/my:MasterDetailsView.ItemTemplate&gt;
    &lt;my:MasterDetailsView.DetailsTemplate&gt;
      &lt;DataTemplate x:DataType="local:Model"&gt;
        &lt;ScrollViewer VerticalScrollMode="Disabled"
                      VerticalScrollBarVisibility="Hidden"
                      HorizontalScrollMode="Enabled"
                      HorizontalScrollBarVisibility="Auto"&gt;
          &lt;StackPanel x:Name="root" Orientation="Horizontal"&gt;
  
            &lt;my:Expander Header="Expander 1" IsExpanded="True"&gt;
              &lt;!-- Should be scrollable! --&gt;
              &lt;ListView ItemsSource="{x:Bind Items}"
                        Style="{StaticResource ListStyle}"
                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                        ScrollViewer.VerticalScrollMode="Enabled"&gt;
                &lt;ListView.ItemTemplate&gt;
                  &lt;DataTemplate x:DataType="x:String"&gt;
                    &lt;TextBlock Text="{x:Bind}" TextWrapping="Wrap"/&gt;
                  &lt;/DataTemplate&gt;
                &lt;/ListView.ItemTemplate&gt;
              &lt;/ListView&gt;
            &lt;/my:Expander&gt;
  
            &lt;my:Expander Header="Expander 2"&gt;&lt;/my:Expander&gt;
            &lt;my:Expander Header="Expander 3"&gt;&lt;/my:Expander&gt;
          &lt;/StackPanel&gt;
        &lt;/ScrollViewer&gt;
      &lt;/DataTemplate&gt;
    &lt;/my:MasterDetailsView.DetailsTemplate&gt;
  &lt;/my:MasterDetailsView&gt;
  </code></pre>