Your original XAML seemed to be quite strange... I'm not surprised it wasn't working. For example, you set the ListView.MaxHeight
property to 100
, but also set the relevant RowDefinition.MaxHeight
property to 150
. Perhaps you meant to do that, I don't know... either way, you just needed to use the *
setting for the Height
property on the ListView
s RowDefinition
, set some VerticalAlignment
properties and remove the inner Grid
that did nothing useful. Try this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Heading" />
<ListView Grid.Row="1" MaxHeight="100" VerticalAlignment="Top">
<ListView.Items>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
</ListView.Items>
</ListView>
<Separator Grid.Row="2" />
<Button Grid.Row="3" Width="75" Height="25" Content="Save"
VerticalAlignment="Top" />
</Grid>
UPDATE >>>
When working with Grid
s, just experiment with the "*"
setting, which will take up all of the remaining space in the Grid
. It's really not that difficult. Try this instead:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Heading"/>
<ListView Grid.Row="0" MaxHeight="100" VerticalAlignment="Top">
<ListView.Items>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
</ListView.Items>
</ListView>
<Separator Grid.Row="1" VerticalAlignment="Top" />
<Button Grid.Row="2" Width="75" Height="25" Content="Save"
VerticalAlignment="Top" />
</Grid>
UPDATE 2 >>>
Ok, so this should now be what you're after:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" MaxHeight="100" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Heading" />
<ListView Grid.Row="1" MinHeight="30" MaxHeight="100" VerticalAlignment="Top">
<ListView.Items>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
<system:Int32>0</system:Int32>
</ListView.Items>
</ListView>
<Separator Grid.Row="2" VerticalAlignment="Top" />
<Button Grid.Row="3" Width="75" Height="25" Content="Save"
VerticalAlignment="Top" />
</Grid>