Xamarin 中的 ViewCell 限制高度显示
ViewCell in Xamarin limited height displayed
我已经为 Xamarin 跨平台应用程序中的设置页面实现了 TableView。在此每个单元格的高度是固定的,并且不会根据内部视图而扩展。如果 ViewCell 是单行高或双行高,则 ViewCell 可以很好地显示项目。如果有多个控件(比如button+2 labels or Label containing paragraph)那么它的高度是有限的,视图不会显示。
<TableSection Title="Settings heading">
<ViewCell>
<!-- Image Type Settings -->
<StackLayout HorizontalOptions="StartAndExpand"
Orientation="Vertical"
VerticalOptions="StartAndExpand">
<StackLayout HorizontalOptions="Fill"
Orientation="Horizontal"
VerticalOptions="StartAndExpand">
<Label HorizontalOptions="StartAndExpand" Text="Key" />
<Label HorizontalOptions="EndAndExpand"
Text="Value"
TextColor="Green" />
</StackLayout>
<Label HorizontalOptions="Fill"
Text="---- Long Long Paragraph here about setting, of which only one line will be rendered in ViewCell ----"
VerticalOptions="StartAndExpand" />
</StackLayout>
</ViewCell>
</TableSection>
我尝试增加 ViewCell、TableView VerticalOptions 的高度,但没有任何效果。
后来发现TableView有属性HasUnevenRows
应该设置为true
HasUnevenRows="True"
我已经为 Xamarin 跨平台应用程序中的设置页面实现了 TableView。在此每个单元格的高度是固定的,并且不会根据内部视图而扩展。如果 ViewCell 是单行高或双行高,则 ViewCell 可以很好地显示项目。如果有多个控件(比如button+2 labels or Label containing paragraph)那么它的高度是有限的,视图不会显示。
<TableSection Title="Settings heading">
<ViewCell>
<!-- Image Type Settings -->
<StackLayout HorizontalOptions="StartAndExpand"
Orientation="Vertical"
VerticalOptions="StartAndExpand">
<StackLayout HorizontalOptions="Fill"
Orientation="Horizontal"
VerticalOptions="StartAndExpand">
<Label HorizontalOptions="StartAndExpand" Text="Key" />
<Label HorizontalOptions="EndAndExpand"
Text="Value"
TextColor="Green" />
</StackLayout>
<Label HorizontalOptions="Fill"
Text="---- Long Long Paragraph here about setting, of which only one line will be rendered in ViewCell ----"
VerticalOptions="StartAndExpand" />
</StackLayout>
</ViewCell>
</TableSection>
我尝试增加 ViewCell、TableView VerticalOptions 的高度,但没有任何效果。
后来发现TableView有属性HasUnevenRows
应该设置为true
HasUnevenRows="True"