Is there a way to only invisible of ListView.ItemTemplate and keep ListView.Header ?

CondaConda Member ✭✭
edited November 2018 in Xamarin.Forms

I find IsVisible attribute only in the itself but don't find in neither <ListView.ItemTemplate> nor <ListView.Header>, So is there a way to only invisible <ListView.ItemTemplate> and keep <ListView.Header> visible?

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    Sorry but I don’t understand your problem. ItemTemplate and Header are separated so there is no problem to hide one and not hide the other
  • CondaConda Member ✭✭

    My problem is I don't find an IsVisible-like attribute for them.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    You should hide the content

    Add a StackLayout to Header and hide the StackLayout
  • CondaConda Member ✭✭

    Thanks for your help Alessandro

    I found I was wrong IsVisible doesn't achieve my purpose as it leaves blank area, is there a way to totally remove it?

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    Where are blank areas ? Can you post an image?
  • CondaConda Member ✭✭

    I want when user taps List1 icon, "List1 ItemTemplate" will be visible/invisible.

    So I tried to invisible it but IsVisible attribute make blank area as I don't want List2 starts from that blank area (below List2 Heading).

  • CondaConda Member ✭✭
    edited November 2018

    Sounds it's a problem with ListView as it takes half of the page explicitly, I created an ContentPage with StackLayout with 2 ListViews as the following code:

    <StackLayout>
        <ListView VerticalOptions="Start">
            <ListView.Header>
                <StackLayout>
                    <Label Text="Header 1"/>
                </StackLayout>
            </ListView.Header>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
    
        </ListView>
        <ListView VerticalOptions="StartAndExpand">
            <ListView.Header>
                <StackLayout>
                    <Label Text="Header 2"/>
                </StackLayout>
            </ListView.Header>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
    
        </ListView>
    

    I set VerticalOptions of List1 to "Start" and "StartAndExpand" to List2.
    I expected List2 starts from the very below of List1 but it doesn't happen, Here is my screenshot:

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    you are using 2 separate listview. Is it correct? Or should be better to have a "grouped" listview?

Sign In or Register to comment.