Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

enter image description here

like image 460
Raven Avatar asked Nov 04 '16 06:11

Raven


1 Answers

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

like image 162
Manoher Kumar Avatar answered Nov 18 '22 07:11

Manoher Kumar