简体   繁体   English

WP7阻止列表框滚动

[英]WP7 Prevent ListBox scrolling

I have a page with two ListBox controls. 我有一个包含两个ListBox控件的页面。 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,其中包含该类别的所有项目,然后是另一个标题,后面跟着该类别的项目列表等。

The issue I'm having is that each ListBox scrolls independently. 我遇到的问题是每个ListBox独立滚动。 I want the whole page to scroll (which it does), but not each individual ListBox. 我希望整个页面滚动(它做),但不是每个单独的ListBox。 The ListBox controls grow automatically to their content, so there is no need to have them scroll. ListBox控件会自动增长到其内容,因此无需滚动它们。 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" ). 为了禁用滚动,你所要做的就是设置ScrollViewer.VerticalScrollBarVisibility="Disabled" (如果你需要禁用水平滚动,那么使用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. 我希望这能回答你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM