简体   繁体   中英

Xamarin Forms IsVisible false taking up space

I have a list view with a template switcher, and a on a particular item I want it to be hidden so I've used a hidden template. I set the view (or the StackLayout) to be isVisible=false and the HeightRequest=0 so that it should not take up space and should not be visible. However as you can see in the picture, it is still taking up an empty space.

In the image below, there are 2 hidden messages. The one before the "This is a Bot Hero Card Message!" and the one after it.

How do you do this to make it not take up space?

在此输入图像描述

Please use Grid in your listview. It will solve your issue. for more info 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>

thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM