我有一个带有模板切换器的 ListView ,并且我希望在特定项目上隐藏它,所以我使用了一个隐藏模板。我将 View (或 StackLayout)设置为 isVisible=false 和 HeightRequest=0,这样它就不会占用空间并且不应该可见。然而,正如您在图片中看到的,它仍然占据了一个空白空间。
在下图中,有 2 条隐藏消息。 “This is a Bot Hero Card Message!”之前的那个以及它之后的那个。
如何做到不占用空间?
最佳答案
请在您的 ListView 中使用网格。它会解决你的问题。 了解更多信息 https://forums.xamarin.com/discussion/83632/hiding-and-showing-stacklayout
<ListView x:Name="ItemList" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Appearing="Cell_OnAppearing" Tapped="ViewCell_Tapped" >
<ViewCell.View>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
谢谢
关于c# - Xamarin Forms IsVisible false 占用空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40416431/