我正在开发一个Windows应用商店应用.
我有一个包含大量项目的ListView.它嵌套在一些堆栈面板和网格中,但它们基本上都是自动调整大小的.从本质上讲,ListView是屏幕右半部分的大部分,无论它的大小是多少.
如果我给ListView一个硬值高度,滚动条将自动出现,没有额外的工作.大.但我不想设置一个高度...我希望它是容器中可用的所有区域.如果我试图聪明并将其设置为9999或其他东西,那么它将不会滚动.
我做了很多研究,像这样的类似问题说,持有ListView的东西不能像StackPanel那样给它无限大小.我有什么替代品?如何将ListView放在具有任意空间的内容中并显示滚动条?
我唯一的想法是,必须有一些方法,在容纳ListView的容器中,告诉ListView它具有所有可用区域,以便它的高度设置为该值.类似于如何将ListViewItem的HorizontalContentAlignment属性设置为'Stretch',以便获取ListView中的项目以了解它们实际具有的可用宽度.
我的布局的基本部分是这样的:
<!-- Nested in some other stuff simple Grids and StackPanels, none of which has hard heights set (all auto or *) -->
<!-- Even if I made this a Grid with one Row, setting definition to * or Auto doesn't help the issue - no scroll bar appears -->
<StackPanel>
<!-- Other stuff that has Visibility="Collapsed"... I have code so that only one item at a time within this container will ever …Run Code Online (Sandbox Code Playgroud)