Xamarin形式IsVisible错误占用空间

Rav*_*ven 7 c# xaml xamarin.forms

我有一个带有模板切换器的列表视图,以及一个特定项目,我希望它被隐藏,所以我使用了一个隐藏的模板.我将视图(或StackLayout)设置为isVisible = false,并将HeightRequest设置为0,这样它就不会占用空间而且不应该是可见的.但是正如你在图片中看到的那样,它仍占据一个空白空间.

在下图中,有2条隐藏的消息.在"这是Bot Hero Card Message!"之前的那个!和之后的那个.

你怎么做这个让它不占用空间?

在此输入图像描述

Man*_*mar 5

请在您的列表视图中使用网格。它将解决您的问题。了解更多信息 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>
Run Code Online (Sandbox Code Playgroud)

谢谢