Random programming things I'd want to remember

Monday, January 20, 2014

System.Windows.Control.ListBox does not scroll

An interesting one today. My ListBox would not scroll, and after looking into all usual suspects it still would not work. Turns out that the offender was the Grid, containing the ListBox. Here is XAML:
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            <StackPanel Orientation="Horizontal">
            <ListBox ItemsSource="{Binding}" Grid.Row="1">
                        <TextBlock Text="{Binding Description}" />

My ListBox has a bunch of items and it does not scroll, even though there is no StackPanel in the DataTemplate. But, if I change the RowDefinition on the second row to say
                <RowDefinition Height="*" />

Then it scrolls just fine.

No comments: