Reputation: 307
I am writing a Windows 10 UWP (Universal Windows Platform) app. The app window contains a ListBox and a button. The ListBox should be taking all the space the window offers, and if not all items fit the ListBox, scrollbars should appear.
How can I "couple" the height of the ListBox to eg the window height - 100 ?
The setting the ListBox.Height parameter to this.Height - 100 does unfortunately accomplish nothing, even when done inside a resize event.
Thank you!!
Upvotes: 2
Views: 493
Reputation: 39006
If I understand your question clearly, this is what you need -
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<ListBox />
<Button Content="Button" HorizontalAlignment="Center" Grid.Row="1" />
</Grid>
You don't need to hard-code the height, instead, you use RowDefinitions
to create two rows inside the Grid
. The ListBox
will occupy the first row and the Button
the second row.
Note that the second row has a height of 100epx
while the first row simply fills the rest of the space.
Upvotes: 3