Bug 60033 - ListView override void SetupContent not triggered in UWP
Summary: ListView override void SetupContent not triggered in UWP
Status: IN_PROGRESS
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.4.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-06 18:10 UTC by Andrew
Modified: 2017-11-17 15:08 UTC (History)
3 users (show)

See Also:
Tags: listview, setupcontent, ac, fr
Is this bug a regression?: ---
Last known good build:


Attachments

Description Andrew 2017-10-06 18:10:18 UTC
Hi there! -

I've struggling with the following. When trying to extend the ListView and overriding the SetupContent()

    public class ListViewExt : ListView
    {
        protected override void SetupContent(Cell cell, int index)
        {
            base.SetupContent(cell, index);

    
        }
    }

This does not get trigger in a UWP project, however on iOS it works fine. What I'm missing here?
Here's the link to the sample project to illustrate. Any guidance on this is much appreciated.

https://gsiccorp-my.sharepoint.com/personal/ancotterell_gsiccorp_net/_layouts/15/guestaccess.aspx?docid=1ca22a7b9d62c4c2f853803dab67da7b1&authkey=AQZ8s3AyfuJRJ6Ue16yDgtU&expiration=2017-11-05T18%3a00%3a12.000Z
Comment 1 Paul DiPietro [MSFT] 2017-10-06 19:26:01 UTC
I think there are some inconsistencies in behavior. Adding a reference to 45689.
Comment 2 Andrew 2017-10-11 19:08:23 UTC
is there a suggested work around as this being looked at? Or do we anticipate a resolution soon?
Comment 3 Paul DiPietro [MSFT] 2017-10-25 22:41:38 UTC
Try this for the time being:

		public class CustomListView : ListView
		{
			public CustomListView() : base()
			{
				TemplatedItems.CollectionChanged += TemplatedItems_CollectionChanged;
			}

			protected override void SetupContent(Cell cell, int index)
			{
				base.SetupContent(cell, index);
			}

			void TemplatedItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
			{
				foreach (var item in TemplatedItems)
					Noop();
			}

			void Noop() { }
		}
Comment 4 Andrew 2017-10-27 17:53:26 UTC
Great... this worked! Much appreciated
Comment 5 Paul DiPietro [MSFT] 2017-10-30 18:30:49 UTC
https://github.com/xamarin/Xamarin.Forms/pull/1240
Comment 6 E 2017-11-17 15:08:52 UTC
@Paul DiPietro

If I implement your workaround, i'm getting the following error

- Unable to cast object of type 'XFLetsGrowApp.UWP.CustomListView' to type 'Xamarin.Forms.IRegisterable'."	string

Note You need to log in before you can comment on or make changes to this bug.