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)

Tags: ac xaml
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 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 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