Home All Groups Group Topic Archive Search About

XAML & Element Arrangements

Author
22 Apr 2007 5:56 PM
hufaunder@yahoo.com
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>

Author
22 Apr 2007 6:48 PM
Deniz Demircioglu
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>

--
Developer,
Microsoft Office


Show quote
"hufaun***@yahoo.com" wrote:

> 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>
>
>

AddThis Social Bookmark Button