ListView in a metro app does not get its vertical scrollbar

坚强是说给别人听的谎言 提交于 2019-12-10 19:18:51

问题


I am not experienced in Windows Store (aka Metro) app XAML, so perhaps I am overlooking something simple, but according to books and samples, a vertical scrollbar is a natural part of a ListView control, and unless explicitly disabled will show up when there are invisible items in the ListView.

But on in the case of my app. I have a typical List/Detail page with items in the left pane - they are displayed fine, with scrollbar, and selected item details in the right pane. Selected item contains a collection of subitems, and they are supposed to be displayed with a scrollbar in case there are many of them. I have a simple ListView definition:

            <ListView 
            x:Name="itemCollection"
            Grid.ColumnSpan="1" 
            SelectionChanged="ItemListView_SelectionChanged"
            ItemsSource="{Binding Elements}" 
            ItemTemplate="{StaticResource Custom80ItemTemplate}" />

Strange enough, I never see a scrollbar for this list. Only when I explicitly set its mode to "Visible", I can see a scroll bar, but there is nothing to scroll it with!

Obviously the program believes that the whole list is visible so scroll bar is unnecessary, but what can make it do such judgement?


回答1:


I've finally fixed the problem. As most of such problems, the error was silly: a Grid control that owns this ListView had an extra (wrong) row definition that had Height property marked with asterisk, i.e. taking all remaining space. But the row that ListView was using had Height marked as "Auto", therefore it expanded to the whole size of its items and never activated its vertical scroll bar.




回答2:


Try Setting the visibility to auto.



来源:https://stackoverflow.com/questions/12682423/listview-in-a-metro-app-does-not-get-its-vertical-scrollbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!