[英]TableView Height Wrapping (Xamarin.Forms)
我的Table View中的物品很少,但是面临着一个挑战,TableView不会根据其中的物品自动包装其高度,TableView很长,但是物品很少,我该如何解决。 以下是我的XAML代码:
<TableView Intent="Form" x:Name="sales_tableView" RowHeight="-1">
<TableView.Root >
<TableSection Title="Agent Sales Details">
<TextCell Text="Agent Number" x:Name="agentNumber_txtcell" DetailColor="Purple" />
<TextCell Text="Agent Rating " x:Name="agentrating_txtcell" DetailColor="Purple"/>
<TextCell Text="Agent Phone " x:Name="agentphone_txtcell" DetailColor="Purple" />
<TextCell Text="Agent Email " x:Name="agentemail_txtcell" DetailColor="Purple" />
</TableSection>
</TableView.Root>
</TableView>
编辑:
这是屏幕截图:
因此,您可以简单地将静态ViewCell添加到包含按钮的表格底部,并按常规方式与后面代码中的click方法挂钩,然后将背景设置为透明。
<TableView Intent="Form" x:Name="sales_tableView" RowHeight="-1">
<TableView.Root >
<TableSection Title="Agent Sales Details">
<TextCell Text="Agent Number" x:Name="agentNumber_txtcell" DetailColor="Purple" />
<TextCell Text="Agent Rating " x:Name="agentrating_txtcell" DetailColor="Purple"/>
<TextCell Text="Agent Phone " x:Name="agentphone_txtcell" DetailColor="Purple" />
<TextCell Text="Agent Email " x:Name="agentemail_txtcell" DetailColor="Purple" />
<ViewCell>
<StackLayout Orientation="Horizontal">
<Button Text="MY CLIENTS" Clicked="MyClickMethod" />
</StackLayout>
</ViewCell>
</TableSection>
</TableView.Root>
</TableView>
我想您可以在XAML中设置背景色,我想您只需添加此属性即可
BackgroundColor="Transparent"
到tableview的xaml,但我不记得是否正确,无论哪种方式,您都可以在后面的代码中执行相同的操作:
sales_tableView.BackgroundColor = Color.Transparent;
<TableView Intent="Settings" HasUnevenRows="true">
注意:HasUnevenRows =“ true”
关于这个问题,这就是我的解决方法,我注意到的是,如果将HeightRequest
的HeightRequest设置为0,1,2 and above
,TableView的高度仍然会很长,所以我只将HeightRequest
设置为值从0,-1,-2,...
所以下面是我的代码示例:
<TableView Intent="Form" x:Name="sales_tableView" RowHeight="-1" HeightRequest="-2">
<TableView.Root >
<TableSection Title="Agent Sales Details">
<TextCell Text="Agent Number" x:Name="agentNumber_txtcell" DetailColor="Purple" />
<TextCell Text="Agent Rating " x:Name="agentrating_txtcell" DetailColor="Purple"/>
<TextCell Text="Agent Phone " x:Name="agentphone_txtcell" DetailColor="Purple" />
<TextCell Text="Agent Email " x:Name="agentemail_txtcell" DetailColor="Purple" />
</TableSection>
</TableView.Root>
</TableView>
希望这有助于编码愉快
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.