我有这个列表视图:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ScrollViewer VerticalScrollBarVisibility="Visible" VerticalScrollMode="Enabled">
<ListView x:Name="entryList" Width="360">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel BorderBrush="Gray">
<TextBlock Text="{Binding title}"></TextBlock>
<TextBlock Text="{Binding description}"></TextBlock>
<TextBlock Text="{Binding author}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollViewer>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我在单独的方法中获取调用 Web 服务的 ItemsSource 的数据(一切正常)
private async void Page_Loading(Windows.UI.Xaml.FrameworkElement sender, object args)
{
entryList.ItemsSource = await webserviceManager.getItems(param1, param2);
}
Run Code Online (Sandbox Code Playgroud)
我的 ListView 也充满了项目,但我不明白为什么它无法垂直滚动。检查 ScrollableHeight 我总是得到 0,所以我认为这些项目是问题所在,到目前为止,控件并未将它们计为逻辑项目。如果我给 ScrollViewer 一个具体的高度,一切都很好 - 但这不是可行的解决方案,因为我不知道应用程序稍后将在哪个设备上运行。所以我不知道我还能做什么,也许有人可以帮助我?
编辑:数据源有一个
ObservableCollection<entryObject> objlist = new ObservableCollection<NewsObject>();
Run Code Online (Sandbox Code Playgroud)
其中entryObject是一个具有字符串属性的简单数据保存类。