Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I prevent the grid splitter from resizing a column outside of the window bounds?
    text
    copied!<p>I have the XAML shown below (for example). If you drag the grid splitter as far as it goes to the left, and keep dragging the mouse, the right-hand column will grow in size outside the bounds of the window - obviously not what I want.</p> <p>The problem is that I can't set a hard MaxWidth on the right-hand column because the user can resize the window, thus increasing the available space for that column. So far I think I need to bind the MaxWidth of the right-hand column to something like the window's client area minus the MinWidth of the left plus the width of the splitter column. But I'd like to avoid that if possible. Thoughts?</p> <pre><code>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="450" Height="300"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*" MinWidth="100" /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;ColumnDefinition Width="200" MinWidth="200" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid Grid.Column="0"&gt; &lt;Button&gt;Monkey&lt;/Button&gt; &lt;/Grid&gt; &lt;GridSplitter Grid.Column="1" Width="7" ResizeBehavior="PreviousAndNext" /&gt; &lt;Grid Grid.Column="2" Margin="4"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;GroupBox Grid.Row="0" Header="Spaghetti" Margin="0, 0, 0, 5"&gt; &lt;ComboBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch"&gt;Noodles&lt;/ComboBox&gt; &lt;/GroupBox&gt; &lt;Expander Grid.Row="1" Header="Batman" IsExpanded="True" Margin="0, 0, 0, 5"&gt; &lt;Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch"&gt;Batman!&lt;/Button&gt; &lt;/Expander&gt; &lt;/Grid&gt; &lt;/Grid&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