15
votes

I have a page with two ListBox controls. The page contains a list of items based on the item's category.

There is a header for a category, followed by a ListBox containing all items for that category, then another header followed a list of items for that category, etc.

The issue I'm having is that each ListBox scrolls independently. I want the whole page to scroll (which it does), but not each individual ListBox. The ListBox controls grow automatically to their content, so there is no need to have them scroll. Is this possible?

1
What should happen when the combined length of the two list boxes is bigger than the screen? It strikes me that this may have usability issues? Also, how would this be different to having one list and changing the items in the bottom part of it based on a selection in the top part?Matt Lacey
The screen is scrollable, so you can scroll down to see the other list boxes if they are longer than the screen.CACuzcatlan

1 Answers

42
votes

All you have to do in order to disable the scroll is just to set ScrollViewer.VerticalScrollBarVisibility="Disabled" (if you need to disable the horizontal scroll then use ScrollViewer.HorizontalScrollBarVisibility="Disabled").

Here is a simple example:

<ListBox Height="200" ScrollViewer.VerticalScrollBarVisibility="Disabled">
    <ListBoxItem >
        <Button Content="item1"  />
    </ListBoxItem>
    <ListBoxItem >
        <Button Content="item2"  />
    </ListBoxItem>
    <ListBoxItem >
        <Button Content="item3"  />
    </ListBoxItem>
    <ListBoxItem >
        <Button Content="item4"  />
    </ListBoxItem>
    <ListBoxItem >
        <Button Content="item5"  />
    </ListBoxItem>
</ListBox>

I hope that this will answer your question.