1

Hi I am trying to get my UI have scrolling in partial page having a list. Here's my code -

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,0,14,10">  
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBox x:Name="searchTerm" Text="potato" Width="379"   />
                    <Button x:Name="btnSearch" Content="Go" Click="btnSearch_Click"  />
                </StackPanel>
                <TextBlock x:Name="noResultsTxt" Visibility="Collapsed" Margin="10, 30, 0, 0" Text="No results found! try different search term" Style="{StaticResource PhoneTextNormalStyle}" />
                <ScrollViewer Height="520" Width="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                    <StackPanel>                                            
                        <ListBox x:Name="itemlist"  SelectionChanged="itemlist_SelectionChanged" Margin="0,10,0,0" >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Margin="10" >
                                        <TextBlock Text="{Binding Title}" FontSize="35" FontWeight="Normal"/>
                                        <TextBlock Text="{Binding CommaCategories}" FontSize="20" FontWeight="Light" FontStyle="Italic"/>
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </StackPanel>
                </ScrollViewer>
            </StackPanel>
        </Grid>        

Doesnt seem to be scrolling at the List area. i seem to have figured out that the issue is with Scrollviewer not able to interact where ListBox exists. I verified that the scrolling is happening perfectly fine by setting IsHitTestVisible property of ListBox to be false.

Can someone help me out!

whihathac
  • 1,741
  • 2
  • 22
  • 38

1 Answers1

4

Answering my own question! Just as AMR commented it, I figured out that I don't need the scroll viewer, I just set the height of ListBox and scrolling worked fine! :)

On why external scrollviewer wont work with Listbox - https://stackoverflow.com/a/1294786/729032

Community
  • 1
  • 1
whihathac
  • 1,741
  • 2
  • 22
  • 38