WP7 Prevent ListBox scrolling
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?
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.
精彩评论