Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get StackPanel's children to fill maximum space downward?
    text
    copied!<p>I simply want flowing text on the left, and a help box on the right.</p> <p>The help box should extend all the way to the bottom.</p> <p>If you take out the outer StackPanel below it works great.</p> <p>But for reasons of layout (I'm inserting UserControls dynamically) I need to have the wrapping StackPanel.</p> <p>How do I get the GroupBox to extend down to the bottom of the StackPanel, as you can see I've tried:</p> <ul> <li>VerticalAlignment="Stretch" </li> <li>VerticalContentAlignment="Stretch" </li> <li>Height="Auto"</li> </ul> <p>XAML:</p> <pre><code>&lt;Window x:Class="TestDynamic033.Test3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Test3" Height="300" Width="600"&gt; &lt;StackPanel VerticalAlignment="Stretch" Height="Auto"&gt; &lt;DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" Margin="10"&gt; &lt;GroupBox DockPanel.Dock="Right" Header="Help" Width="100" Background="Beige" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" Height="Auto"&gt; &lt;TextBlock Text="This is the help that is available on the news screen." TextWrapping="Wrap" /&gt; &lt;/GroupBox&gt; &lt;StackPanel DockPanel.Dock="Left" Margin="10" Width="Auto" HorizontalAlignment="Stretch"&gt; &lt;TextBlock Text="Here is the news that should wrap around." TextWrapping="Wrap"/&gt; &lt;/StackPanel&gt; &lt;/DockPanel&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre> <h2>Answer:</h2> <p>Thanks Mark, using DockPanel instead of StackPanel cleared it up. In general, I find myself using DockPanel more and more now for WPF layouting, here's the fixed XAML:</p> <pre><code>&lt;Window x:Class="TestDynamic033.Test3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Test3" Height="300" Width="600" MinWidth="500" MinHeight="200"&gt; &lt;DockPanel VerticalAlignment="Stretch" Height="Auto"&gt; &lt;DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" MinWidth="400" Margin="10"&gt; &lt;GroupBox DockPanel.Dock="Right" Header="Help" Width="100" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" Height="Auto"&gt; &lt;Border CornerRadius="3" Background="Beige"&gt; &lt;TextBlock Text="This is the help that is available on the news screen." TextWrapping="Wrap" Padding="5"/&gt; &lt;/Border&gt; &lt;/GroupBox&gt; &lt;StackPanel DockPanel.Dock="Left" Margin="10" Width="Auto" HorizontalAlignment="Stretch"&gt; &lt;TextBlock Text="Here is the news that should wrap around." TextWrapping="Wrap"/&gt; &lt;/StackPanel&gt; &lt;/DockPanel&gt; &lt;/DockPanel&gt; &lt;/Window&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload