summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-08-15 22:18:26 +0200
committerJason Smith <jason.smith@xamarin.com>2016-08-15 13:18:26 -0700
commita1126ab66bc9bd41cfa32dbefbe5758bcf5b4b32 (patch)
treed586aaffcf721ef9cd7558335757050a9c8b1f2e /Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
parent90396b0ffdecf65b8e2eea8eb4f148bdea1071c4 (diff)
downloadxamarin-forms-a1126ab66bc9bd41cfa32dbefbe5758bcf5b4b32.tar.gz
xamarin-forms-a1126ab66bc9bd41cfa32dbefbe5758bcf5b4b32.tar.bz2
xamarin-forms-a1126ab66bc9bd41cfa32dbefbe5758bcf5b4b32.zip
[Xaml] Simplify listnodes with single elements (#304)
Diffstat (limited to 'Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs')
-rw-r--r--Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs18
1 files changed, 13 insertions, 5 deletions
diff --git a/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs b/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
index 1e332323..108d707e 100644
--- a/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
+++ b/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
@@ -102,21 +102,29 @@ namespace Xamarin.Forms.Xaml
value = valueProvider.ProvideValue(serviceProvider);
}
- XmlName propertyName;
- if (TryGetPropertyName(node, parentNode, out propertyName))
- {
+ XmlName propertyName = XmlName.Empty;
+
+ //Simplify ListNodes with single elements
+ var pList = parentNode as ListNode;
+ if (pList != null && pList.CollectionItems.Count == 1) {
+ propertyName = pList.XmlName;
+ parentNode = parentNode.Parent;
+ parentElement = parentNode as IElementNode;
+ }
+
+ if (propertyName != XmlName.Empty || TryGetPropertyName(node, parentNode, out propertyName)) {
if (Skips.Contains(propertyName))
return;
if (parentElement.SkipProperties.Contains(propertyName))
return;
- var source = Values[parentNode];
+ var source = Values [parentNode];
if (propertyName == XmlName._CreateContent && source is ElementTemplate)
SetTemplate(source as ElementTemplate, node);
else
SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
- }
+ }
else if (IsCollectionItem(node, parentNode) && parentNode is IElementNode)
{
// Collection element, implicit content, or implicit collection element.