Reputation: 122412
The following XAML works fine:
<Grid x:Name="LayoutRoot" Background="Transparent">
<ListBox x:Name="StoryListBox"/>
</Grid>
The ListBox
scrolls appropriately when there is too much content to fit on a single screen.
However, I modify the XAML as follows, and it breaks:
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBox x:Name="LoadingMessage" Text="Loading..." Grid.Row="0" />
<ListBox x:Name="StoryListBox" Grid.Row="0" />
<Button x:Name="LoadMoreStories" Content="Load More Stories" Grid.Row="1" Visibility="Collapsed"/>
</Grid>
Now, the ListBox
only scrolls down a tiny bit, even though it has overflowed content.
How did I mess it up?
Update: I also tried the following, but it still doesn't work:
<Grid x:Name="LayoutRoot" Background="Transparent">
<StackPanel x:Name="Loading">
<TextBox Text="Loading..." />
<ProgressBar IsIndeterminate="True" Style="{StaticResource PerformanceProgressBar}" />
</StackPanel>
<ScrollViewer>
<StackPanel>
<ListBox x:Name="StoryListBox" />
<Button x:Name="LoadMoreStories" Content="Load More Stories" Visibility="Collapsed"/>
</StackPanel>
</ScrollViewer>
</Grid>
It has the same issue of the ListBox
only scrolling down a tiny bit.
Upvotes: 1
Views: 715
Reputation: 14994
It scrolls properly but the size of List box is bigger than page. Try setting the size explicite.
<StackPanel Orientation="Horizontal" Height="500">
<TextBox x:Name="LoadingMessage" Text="Loading..." Grid.Row="0" />
<ListBox x:Name="StoryListBox" Grid.Row="0" >
<ListBoxItem Content="a"></ListBoxItem>
<ListBoxItem Content="b"></ListBoxItem>
<ListBoxItem Content="c"></ListBoxItem>
<ListBoxItem Content="d"></ListBoxItem>
<ListBoxItem Content="e"></ListBoxItem>
<ListBoxItem Content="f"></ListBoxItem>
<ListBoxItem Content="g"></ListBoxItem>
<ListBoxItem Content="h"></ListBoxItem>
<ListBoxItem Content="i"></ListBoxItem>
<ListBoxItem Content="j"></ListBoxItem>
<ListBoxItem Content="k"></ListBoxItem>
<ListBoxItem Content="l"></ListBoxItem>
<ListBoxItem Content="1"></ListBoxItem>
<ListBoxItem Content="2"></ListBoxItem>
<ListBoxItem Content="3"></ListBoxItem>
<ListBoxItem Content="4"></ListBoxItem>
<ListBoxItem Content="5"></ListBoxItem>
<ListBoxItem Content="6"></ListBoxItem>
<ListBoxItem Content="7"></ListBoxItem>
<ListBoxItem Content="8"></ListBoxItem>
<ListBoxItem Content="9"></ListBoxItem>
<ListBoxItem Content="10"></ListBoxItem>
<ListBoxItem Content="11"></ListBoxItem>
<ListBoxItem Content="12"></ListBoxItem>
<ListBoxItem Content="13"></ListBoxItem>
<ListBoxItem Content="14"></ListBoxItem>
</ListBox>
</StackPanel>
Upvotes: 0
Reputation: 6033
Try this instead
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
Upvotes: 2