Bug 51961 - iOS: Dynamically show/hide Header or Footer of Xamarin.Forms.ListView
Summary: iOS: Dynamically show/hide Header or Footer of Xamarin.Forms.ListView
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.3.3
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-01-30 16:06 UTC by Florian
Modified: 2018-04-18 14:20 UTC (History)
13 users (show)

Tags: ios, listview, footer ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 51961 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Florian 2017-01-30 16:06:05 UTC
<ListView x:Name="ListView" Header="{Binding .}">

    <ListView.FooterTemplate>
        <DataTemplate>
            <Label Text="No Elements found." IsVisible="{Binding FooterIsVisible}" >
                <Label.Triggers>
                    <Trigger TargetType="Label" Property="IsVisible" Value="False">
                        <Setter Property="HeightRequest" Value="0" />
                    </Trigger>
                </Label.Triggers>
            </Label>
        </DataTemplate>
    </ListView.FooterTemplate>

    <!-- ... -->

</ListView>

In the BindingContext I have declared the FooterIsVisible property. When it is false, the footer should be invisible. However this is not working, the Footer is always consuming a certain space for the Label at the bottom of the ListView. 

I did try it on both iOS and Android. On Android it works, the Footer becomes invisible and the height to 0. 

So the problem only exists on iOS. Once the footer has been visible, it will remain to consume that same space even when invisible.

Also see the unsovled question here:
http://stackoverflow.com/questions/41895092/dynamically-show-hide-header-or-footer-of-xamarin-forms-listview/41896468
Comment 1 Jimmy [MSFT] 2017-02-27 18:35:24 UTC
Thank you for filing this report! I will look into creating a sample project based on the information you have provided to try and confirm this issue and I will update the report as necessary.
Comment 2 Florian CHAUX 2017-05-11 08:24:55 UTC
I confirm this issue.
Comment 3 Aaron Kiander 2017-05-12 21:48:11 UTC
Please provide an update on this issue. This issue is negatively impacting our app deliverable right now. Can someone comment on progress?
Comment 4 Aaron Kiander 2017-05-12 21:48:34 UTC
Also - is there a known workaround?
Comment 5 Joe Bowser 2017-06-27 17:34:45 UTC
Has there been any updates on this.  Listview footers seem completely unresponsive to binding on iOS.
Comment 6 Anaïs 2018-01-31 10:45:39 UTC
Hello, I have the same behavior on iOS. Any updates ?
Comment 7 Yulian 2018-04-04 11:44:04 UTC
The same annoying issue found but with simple hotfix:

If you want to hide Header - save ListView Header instance to local value and then set it to NULL:

//...
private object mHeader;
//...
mHeader = mListView.Header;
mListView.Header = null;
//...

If you want to show ListView Header - just set it from local value:

//...
mListView.Header = mHeader;
//...

This fix is 100% crutch - but it helps our team to release our app in time. Microsoft - please take care of your community, because right now our app has so many crutches in our source code that even beautiful c# syntaks doesn't help! I hope you will fix that issue.
Comment 8 daspuru 2018-04-17 21:38:31 UTC
If you have a binded variable to show the header when there is no items on the list, or any ViewModel bool property, you can place this snippet as a workaround with XAML:

<ListView.Triggers>
   <DataTrigger TargetType="ListView" Binding="{Binding HasNoItemsView}" Value="False">
      <Setter Property="Header" Value=""/>
   </DataTrigger>
</ListView.Triggers>
Comment 9 daspuru 2018-04-18 14:20:53 UTC
Better version, this workaround fixes the issue in XAML!


<ListView.Triggers>
   <DataTrigger TargetType="ListView" Binding="{Binding HasNoItemsView}" Value="False">
      <Setter Property="Header" Value=""/>
   </DataTrigger>
   <DataTrigger TargetType="ListView" Binding="{Binding HasNoItemsView}" Value="True">
      <Setter Property="Header" Value="{Binding Path=Header, Source={x:Reference FileItemsListView}}"/>
   </DataTrigger>
</ListView.Triggers>

FileItemsListView is the x:Name attribute for the ListView.