WP7 prevent框滚动prevent

2023-09-03 04:43:26 作者:听闻青春十言九妄

我有两个列表框控件的页面。该页面包含基于该项目的种类项目列表。

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滚动。我希望整个页面滚动(它不会),但不是每一个人列表框。列表框控件自动增长到他们的内容,所以没有必要让他们滚动。这可能吗?

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 =已禁用(如果你需要禁用水平滚动,然后使用 ScrollViewer.Horizo​​ntalScrollBarVisibility =已禁用)。

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.