summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core
diff options
context:
space:
mode:
authorwplong11 <wplong11@naver.com>2017-03-20 21:06:20 +0900
committerRui Marinho <me@ruimarinho.net>2017-03-20 12:06:20 +0000
commitf98e1525c15ca77ec9840c2b5c8020b1b320b141 (patch)
tree46bbe9afc82c275da3828f486dcf63821f7e2a0a /Xamarin.Forms.Core
parentce068193286c5fcebe3fe01fd5edfbbac88e4058 (diff)
downloadxamarin-forms-f98e1525c15ca77ec9840c2b5c8020b1b320b141.tar.gz
xamarin-forms-f98e1525c15ca77ec9840c2b5c8020b1b320b141.tar.bz2
xamarin-forms-f98e1525c15ca77ec9840c2b5c8020b1b320b141.zip
[Core] Fix internal children clear logic (#820)
* Fix InternalChildren clear logic * Improve InternalChildren clear logic * Add test code to verify InternalChildren clear logic * Add missing test cases * Improve time complexity of clear logic * Fix the test case where InvalidOperationException occurs. * Correct the name casing of the test case * Modify a wrong test code
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r--Xamarin.Forms.Core/TemplateUtilities.cs8
1 files changed, 4 insertions, 4 deletions
diff --git a/Xamarin.Forms.Core/TemplateUtilities.cs b/Xamarin.Forms.Core/TemplateUtilities.cs
index 4a8d21b9..e78f4836 100644
--- a/Xamarin.Forms.Core/TemplateUtilities.cs
+++ b/Xamarin.Forms.Core/TemplateUtilities.cs
@@ -58,9 +58,9 @@ namespace Xamarin.Forms
var newElement = (Element)newValue;
if (self.ControlTemplate == null)
{
- for (var i = 0; i < self.InternalChildren.Count; i++)
+ while (self.InternalChildren.Count > 0)
{
- self.InternalChildren.Remove(self.InternalChildren[i]);
+ self.InternalChildren.RemoveAt(self.InternalChildren.Count - 1);
}
if (newValue != null)
@@ -104,9 +104,9 @@ namespace Xamarin.Forms
}
// Now remove all remnants of any other children just to be sure
- for (var i = 0; i < self.InternalChildren.Count; i++)
+ while (self.InternalChildren.Count > 0)
{
- self.InternalChildren.Remove(self.InternalChildren[i]);
+ self.InternalChildren.RemoveAt(self.InternalChildren.Count - 1);
}
ControlTemplate template = self.ControlTemplate;