Bug 28222 - ListView.Footer cannot be set to a StackLayout
Summary: ListView.Footer cannot be set to a StackLayout
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.1
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-20 02:46 UTC by Erik Hougaard
Modified: 2015-05-12 16:38 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test Sample (4.64 MB, application/zip)
2015-03-25 07:05 UTC, Abhishek
Details


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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Erik Hougaard 2015-03-20 02:46:15 UTC
Setting ListView.Footer to a StackLayout creates an exception, changing the Footer to a Label works. (BoxView also produces an exception).


System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnFooterMeasureInvalidated (System.Object sender, System.EventArgs eventArgs) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.VisualElement.InvalidateMeasure () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.StackLayout.InvalidateMeasure () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Layout.OnChildMeasureInvalidated () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Layout.OnChildMeasureInvalidated (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.VisualElement.InvalidateMeasure () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.VisualElement.set_IsPlatformEnabled (Boolean value) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.Platform.<.cctor>b__27 (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.Platform.SetRenderer (Xamarin.Forms.BindableObject bindable, IVisualElementRenderer value) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.VisualElement].SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.VisualElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateFooter () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1 e) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.ListView].SetElement (Xamarin.Forms.ListView element) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.ListView].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.VisualElement].SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.VisualElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x00000] in <filename unknown>:0
  at at (wrapper managed-to-native) ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
  at UIKit.UIViewController.get_View () [0x00030] in /Developer/MonoTouch/Source/monotouch/src/build/native/UIKit/UIViewController.g.cs:2483
  at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.TabbedRenderer.SetupPage (Xamarin.Forms.Page page, Int32 index) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.TabbedRenderer.Reset () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.NotifyCollectionChangedEventArgsExtensions.Apply (System.Collections.Specialized.NotifyCollectionChangedEventArgs self, System.Action`3 insert, System.Action`2 removeAt, System.Action reset) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.TabbedRenderer.OnPagesChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.TabbedRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage (Xamarin.Forms.Page page) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPushAsync>d__1c.MoveNext () [0x00000] in <filename unknown>:0
  at --- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62
  at System.Runtime.CompilerServices.TaskAwaiter`1[System.Boolean].GetResult () [0x00034] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.CompilerServices/TaskAwaiter_T.cs:59
  at Xamarin.Forms.NavigationPage+<PushAsyncInner>d__16.MoveNext () [0x00000] in <filename unknown>:0
  at --- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00034] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.CompilerServices/TaskAwaiter.cs:60
  at Xamarin.Forms.NavigationPage+<PushAsync>d__11.MoveNext () [0x00000] in <filename unknown>:0
  at --- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00034] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.CompilerServices/TaskAwaiter.cs:60
  at GlomarisDistance.MainmenuPage+<MainmenuPage>c__async1.MoveNext () [0x00022] in /Users/eh/Projects/GlomarisDistance/GlomarisDistance/MainmenuPage.cs:25
Comment 1 Abhishek 2015-03-25 07:05:54 UTC
Created attachment 10493 [details]
Test Sample

I have tried this issue and unable to reproduce the reported behavior at my end.

Steps to Reproduce:
1. Create a Xamarin forms application(PCL).
2. Add a Form Content page to a solution.
3. Create ListView  and add header and footer in it.
4. Call ListView.Footer to a StackLayout.
5. Run the application.

Screencast: http://www.screencast.com/t/qdkF8iiS

Could you please attach the test sample along with the bug.So that I can reproduce the reported behavior at my end.Also provide the IDE Log and Environment Info via
IDE Log:Help->Open Log Directory.
Environment Info->Xamarin Studio->About Xamarin Studio->Show Details.

I have also attached my sample which include my implementation. But I am not sure that my efforts included in sample are correct. So you can review it with my attached sample. 

Environment Info:

Xamarin.Forms: 1.4.1.6347-pre2
=== Xamarin Studio ===

Version 5.9 (build 301)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
Runtime:
	Mono 4.0.0 ((detached/9e58200)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000106

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.Android ===

Version: 5.1.0.82 (Enterprise Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: 8.10.0.156 (Enterprise Edition)
Hash: e18cdfd
Branch: master
Build date: 2015-03-24 20:05:18-0400

=== Xamarin.Mac ===

Version: 2.0.0.156 (Enterprise Edition)

=== Build Information ===

Release ID: 509000301
Git revision: eac5f3400f7693042e03dbdf4687449581ee8000
Build date: 2015-03-24 12:34:18-04
Xamarin addins: fb8773221226b0f920a1038e741081fa9cc6ec97

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 Erik Hougaard 2015-03-25 09:51:40 UTC
I'm not using XAML nor the templates, this is a snippet of the code:

Button AddAnotherPortButton = new Button {
  Style = GI.ButtonStyle,
  Text = "Add another port",
};

AddAnotherPortButton.Clicked += async delegate(object sender, EventArgs e) {
  await Navigation.PushAsync(new PortSearchPage();
  Navigation.RemovePage(this);
};

StackLayout FootStack = new StackLayout {
  Orientation = StackOrientation.Horizontal,
  Children = { AddAnotherPortButton /* Plus more controls */ }
};

// This works:
WaypointsList.Footer = AddAnotherPortButton;

// this dosent works and produces the error reported
WaypointsList.Footer = FootStack;

I'm fully updated on the stable channel and all nugets are updated. (Forms = 1.4.0.6341)
Comment 3 Erik Hougaard 2015-03-25 11:13:15 UTC
BTW: It in a shared project.
Comment 4 Christian Schmitt 2015-05-03 07:58:57 UTC
Same problem here. Its not working with a grid or Stackpanel

 <ListView.HeaderTemplate >
      <DataTemplate>
        <StackLayout Orientation="Horizontal">
          <Label Text="Runde" HorizontalOptions="FillAndExpand"/>
          <Label Text="{Binding Player1.Name}" HorizontalOptions="FillAndExpand"/>
          <Label Text="{Binding Player2.Name}" HorizontalOptions="FillAndExpand"/>
          <Label Text="{Binding Player3.Name}" HorizontalOptions="FillAndExpand"/>
          <Label Text="{Binding Player4.Name}" HorizontalOptions="FillAndExpand"/>
        </StackLayout>
      </DataTemplate>
    </ListView.HeaderTemplate>
    <ListView.FooterTemplate>
      <DataTemplate>
        <StackLayout Orientation="Horizontal">
          <Label Text="Runde" HorizontalOptions="FillAndExpand"/>
          <Label Text="{Binding SumPoints1}" HorizontalOptions="FillAndExpand"/>
          <Label Text="{Binding SumPoints2}" HorizontalOptions="FillAndExpand"/>
          <Label Text="{Binding SumPoints3}" HorizontalOptions="FillAndExpand"/>
          <Label Text="{Binding SumPoints4}" HorizontalOptions="FillAndExpand"/>
        </StackLayout>
      </DataTemplate>
    </ListView.FooterTemplate>

Does not work for me
Comment 5 Christian Schmitt 2015-05-03 08:08:01 UTC
Ok it's fixed in 1.4.3.6358-pre2