xaml make listbox stretch with form

  • Thread starter Thread starter mp
  • Start date Start date
M

mp

the following xaml gives me a form with 4 listboxes
the listboxes resize horizontally correctly as the form is stretched
they do not resize vertically as the form is stretched
the margins above/below the listboxes and the top/bottom edge of form
increases as the form is stretched larger in height
how do i make the bottom edge of the listboxes stick to the bottom edge of
the form?
i tried
<Grid Height="568*" >

thinking the * told a control to follow it's container but it gives an error

Error 1 '568*' string cannot be converted to Length.

thanks
mark


<Window x:Class="LispViewer.Window1"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="Window1" Height="590" Width="1106" Loaded="Window_Loaded">

<Grid Height="568" >

<Grid.ColumnDefinitions>

<ColumnDefinition Width="375*" />

<ColumnDefinition Width="375*" />

<ColumnDefinition Width="375*" />

</Grid.ColumnDefinitions>

<ListBox Name="lbOrig" Margin="50,25,0,0" />

<ListBox Name="lbComments" Margin="0,25,0,0" />

<ListBox Name="lbStripped" Margin="0,25,0,0" />

<Button Height="23" Name="button1" VerticalAlignment="Top"
Click="button1_Click" HorizontalAlignment="Left" Width="91">Button</Button>

<ListBox HorizontalAlignment="Left" Margin="1,25,0,0" Name="listBox1"
Width="52" />

</Grid>

</Window>
 
gene kelley said:
Your xaml and desired outcome are a bit conflicting in that your xaml
specifies fixed sizes in which case the contents would not stretch
beyond those limits.

If you actually mean that some of the specified size are Minimum
Sizes, try this example:

<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition MinHeight="578" Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition MinWidth="375" Width="*" />
<ColumnDefinition MinWidth="375" Width="*"/>
<ColumnDefinition MinWidth="375" Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
Height="23" Name="button1" VerticalAlignment="Top"
Click="button1_Click"
HorizontalAlignment="Left" Width="91"
Margin="1,1,1,25" >Button</Button>

<ListBox Grid.Column="0" Grid.Row="1" Name="listBox1"
Width="52" >
<ListBoxItem Content="listbox1"/>
</ListBox>
<ListBox Grid.Column="1" Grid.Row="1" Name="lbOrig"
Margin="50,0,0,0" >
<ListBoxItem Content="lbOrig"/>
</ListBox>
<ListBox Grid.Column="2" Grid.Row="1" Name="lbComments">
<ListBoxItem Content="lbComments"/>
</ListBox>
<ListBox Grid.Column="3" Grid.Row="1" Name="lbStripped" >
<ListBoxItem Content="lbStripped"/>
</ListBox>
</Grid>
</ScrollViewer>

Good Luck,
Gene

thanks,
i just started dragging tools from the toolbox and messed with the xaml
created a bit- no idea what i'm doing...thanks for the example, i see how
you're using the *,
thanks
mark
 
Back
Top