XAML & Element Arrangements

  • Thread starter Thread starter hufaunder
  • Start date Start date
H

hufaunder

I have a grid. In one of the cells I want to show a list box that has
a lot of entries. The problem is that as soon as I put the list box in
a stack panel the list has its full length, i.e. not vertical scroll
bar. As a consequence it extends beyond the window. How do I limit the
size of the list box so everything fits into the cell/stack panel.

<StackPanel Height="Auto" Name="StackPanelFunctions" Grid.Column="0"
Grid.Row="0">
<ListBox Height="Auto" Width="Auto" />
<TextBox>My Text Box</TextBox>
</StackPanel>
 
Either remove the Height="Auto" and Width="Auto" from ListBox and give them
absolute pixel sizes, or instead of using a StackPanel, try using a DockPanel
with LastChildFill set to true:
<Grid>
<DockPanel LastChildFill="True">
<TextBox DockPanel.Dock="Bottom">My Text Box</TextBox>
<ListBox Height="Auto" Width="Auto" />
</DockPanel>
</Grid>
 
Back
Top