WP7阻止列表框滚动

CAC*_*lan 15 .net silverlight listbox windows-phone-7

我有一个包含两个ListBox控件的页面.该页面包含基于项目类别的项目列表.

有一个类别的标题,后跟一个ListBox,其中包含该类别的所有项目,然后是另一个标题,后面跟着该类别的项目列表等.

我遇到的问题是每个ListBox独立滚动.我希望整个页面滚动(它做),但不是每个单独的ListBox.ListBox控件会自动增长到其内容,因此无需滚动它们.这可能吗?

小智 42

您只需要设置ScrollViewer.VerticalScrollBarVisibility="Disabled"(如果您需要禁用水平滚动然后使用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>
Run Code Online (Sandbox Code Playgroud)

我希望这能回答你的问题.