繁体   English   中英

W7P ListBox不会在模拟器中滚动

[英]W7P ListBox doesn't stay scrolled in the emulator

我在Windows Phone 7应用的xaml页面中有一个ListBox。 它开始是空的,然后在从Web服务中检索到某些项目后就填充它们。 到目前为止,一切正常-项目显示在列表中,而且一切似乎都很好。 我遇到的问题是,当我尝试将列表拖动到底部(在模拟器中)时:我可以向下滚动,但是一旦松开鼠标按钮,列表就会跳回到顶部,就好像我没有完全滚动。 为什么它会以这种方式表现出任何见解?

<Grid x:Name="ContentPanel" Grid.Row="2" Margin="0,0,0,0" Canvas.ZIndex="0">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/> <!-- EDIT: the problem was "Auto" here should have been "*" -->
    </Grid.RowDefinitions>

    <!-- removed other element for brevity -->

    <ListBox Name="InfoBoardListBox" Grid.Row="1" SelectionChanged="InfoBoardListBox_SelectionChanged"
              Margin="0,0,0,0" FontSize="26.667" />
</Grid>

以及填充列表的方法:

    foreach (InfoBoard entry in boards.Values) {
        item = new ListBoxItem();
        item.Content = entry.Name;
        item.Name = entry.Id.ToString(); //used to tell which entry was clicked
        InfoBoardListBox.Items.Add(item);
    }

尝试将第二行的高度设置为*而不是Auto 我认为这与ListBox认为的大小与可用空间有关。

暂无
暂无

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

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