我有一个包含两个 ListBox 控件的页面.该页面包含基于项目类别的项目列表.
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.
我遇到的问题是每个 ListBox 都是独立滚动的.我希望整个页面滚动(它确实如此),但不是每个单独的 ListBox.ListBox 控件会根据其内容自动增长,因此无需滚动它们.这可能吗?
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?
要禁用滚动,您只需设置 ScrollViewer.VerticalScrollBarVisibility="Disabled"
(如果需要要禁用水平滚动,然后使用 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
).
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"
).
这是一个简单的例子:
<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.
这篇关于WP7 防止列表框滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!