【发布时间】:2020-05-12 05:05:37
【问题描述】:
我阅读了许多 stackoverflow 文章以了解如何设置 ListView 的高度,以便 ListView 与其内容一样高。
但是许多答案都不能解决我的需求。
我尝试调整https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/workingwithlistview/ 中的基本列表示例 使用此代码
<AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<StackLayout AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1">
<ScrollView>
<StackLayout>
<StackLayout VerticalOptions="StartAndExpand">
<Label Text="Hallo"/>
</StackLayout>
<StackLayout VerticalOptions="StartAndExpand" >
<ListView x:Name="listView" BackgroundColor="Green" VerticalOptions="Start"
ItemsSource="{Binding .}" >
<ListView.Footer>
<Label />
</ListView.Footer>
</ListView>
</StackLayout>
<StackLayout>
<Label Text="Hallosdf"/>
</StackLayout>
</StackLayout>
</ScrollView>
</StackLayout>
</AbsoluteLayout>
但无论我做什么,都会导致列表太高。绿色元素是超大的列表视图。列表视图下方的所有内容都在视口之外。
非常感谢。 乌韦
【问题讨论】:
标签: listview xamarin xamarin.forms