Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get controls in WPF to fill available space?
    text
    copied!<p>Some WPF controls (like the <code>Button</code>) seem to happily consume all the availible space in its' container if you don't specify the height it is to have.</p> <p>And some, like the ones I need to use right now, the (multiline) <code>TextBox</code> and the <code>ListBox</code> seem more worried about just taking the space necessary to fit their contents, and no more. </p> <p>If you put these guys in a cell in a <code>UniformGrid</code>, they will expand to fit the available space. However, <code>UniformGrid</code> instances are not right for all situations. What if you have a grid with some rows set to a * height to divide the height between itself and other * rows? What if you have a <code>StackPanel</code> and you have a <code>Label</code>, a <code>List</code>and a <code>Button</code>, how can you get the list to take up all the space not eaten by the label and the button?</p> <p>I would think this would really be a basic layout requirement, but I can't figure out how to get them to fill the space that they could (putting them in a <code>DockPanel</code> and setting it to fill also doesn't work, it seems, since the <code>DockPanel</code> only takes up the space needed by its' subcontrols).</p> <p>A resizable GUI would be quite horrible if you had to play with <code>Height</code>, <code>Width</code>, <code>MinHeight</code>, <code>MinWidth</code> etc. </p> <p>Can you bind your <code>Height</code> and <code>Width</code> properties to the grid cell you occupy? Or is there another way to do this?</p>
 

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