我有這樣的ListView:UWP C#ListView控件不滾動
<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>
我得到我的數據的ItemsSource在一個單獨的方法調用Web服務(適用所有罰款)
private async void Page_Loading(Windows.UI.Xaml.FrameworkElement sender, object args)
{
entryList.ItemsSource = await webserviceManager.getItems(param1, param2);
}
我的ListView充滿項目,但我不明白爲什麼它不能夠垂直滾動。檢查ScrollableHeight我總是得到0,所以我認爲這些項目是問題,控制不會將它們視爲迄今爲止的邏輯項目。如果我爲ScrollViewer提供一個具體的高度,一切都很好 - 但是這並沒有可行的解決方案,因爲我不知道應用程序稍後將在哪個設備上運行。所以我不知道我能做些什麼,也許有人可以幫助我?
編輯:數據源得到了
ObservableCollection<entryObject> objlist = new ObservableCollection<NewsObject>();
其中entryObject是持有類的字符串屬性的簡單數據。
嗨安德里謝謝你的回答,但這並沒有改變任何東西。 –