This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 45179 - Views in DataTemplate's are being created without the template ever loading.
Summary: Views in DataTemplate's are being created without the template ever loading.
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-10-07 15:41 UTC by Brad Chase
Modified: 2017-01-25 14:07 UTC (History)
8 users (show)

See Also:
Tags: ac xaml
Is this bug a regression?: ---
Last known good build:


Attachments

Description Brad Chase 2016-10-07 15:41:33 UTC
Repro:

Put a DataTemplate in xaml.  Put a ContentView in that DataTemplate.  Put a break point on the constructor.  Load the main xaml up in debug and notice the breakpoint is being hit on the constructor of the ContentView that is in the DataTemplate.  That should not be happening, especially for users that use alot of DataTemplates.  VERY slow.
Comment 1 Brad Chase 2016-10-26 17:25:06 UTC
Could someone update when they think this will be put through?  We have multiple views that have to load multiple times and causes a large wait time when loading on android, I mean up to 30 seconds to load a view only to have to go through the entire wait again once we actually create the views.  This is very important to us to be able to release a speedy android app.  Thanks!
Comment 2 Brad Chase 2016-10-28 21:40:37 UTC
I unfortunately cannot get the forms solution to work with my project.  Has anyone been able to get it to work?  If so is there some information somewhere?  I keep running into different problems with the <UsingTask TaskName="Xamarin.Forms.Build.Tasks.FixedCreateCSharpManifestResourceName" AssemblyFile="Xamarin.Forms.Build.Tasks.dll"/> task.

So anyways I believe the problem in code is in the XamlNode.cs file in two spots where the original code looks like:
		public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
		{
			if (!visitor.VisitChildrenFirst)
				visitor.Visit(this, parentNode);
		    if ((!visitor.StopOnDataTemplate || !IsDataTemplate(this, parentNode)) &&
		        (!visitor.StopOnResourceDictionary || !IsResourceDictionary(this, parentNode)))
		    {
		        foreach (var node in Properties.Values.ToList())
		            node.Accept(visitor, this);
		        foreach (var node in CollectionItems)
		            node.Accept(visitor, this);
		    }

		    if (visitor.VisitChildrenFirst)
		            visitor.Visit(this, parentNode);
		}

and this is what I believe it should look like:
		public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
		{
			if (!visitor.VisitChildrenFirst)
				visitor.Visit(this, parentNode);
		    if ((!visitor.StopOnDataTemplate || !IsDataTemplate(this, parentNode)) &&
		        (!visitor.StopOnResourceDictionary || !IsResourceDictionary(this, parentNode)))
		    {
		        foreach (var node in Properties.Values.ToList())
		            node.Accept(visitor, this);
		        foreach (var node in CollectionItems)
		            node.Accept(visitor, this);

		        if (visitor.VisitChildrenFirst)
		            visitor.Visit(this, parentNode);
		    }
		}
Comment 3 Brad Chase 2016-10-31 12:59:07 UTC
ok I went ahead and put the code in on the Xamarin.Forms-release-2.3.2-hf1 build.  I tried the other builds and the latest code on github but they all have one problem or another.  None of the 2.3.3 builds seem to work and just bomb right out for us without any code changes and also directly from Nuget.  The build I mentioned works perfectly for us without AND WITH the fix put in so we are using that for deploy.
Comment 4 Stephane Delcroix 2017-01-17 14:22:59 UTC
see https://github.com/xamarin/Xamarin.Forms/pull/683
Comment 5 Brad Chase 2017-01-17 16:34:47 UTC
You are the man Stephane!  I will try to pull down the latest and compile and test it out when I get a little time here.
Comment 6 Stephane Delcroix 2017-01-25 14:07:01 UTC
this fix will be available in 2.3.5

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