【发布时间】:2011-04-12 11:12:46
【问题描述】:
我在 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);
}
【问题讨论】:
标签: silverlight xaml windows-phone-7 listbox scroll