diff options
Diffstat (limited to 'Xamarin.Forms.Xaml')
-rw-r--r-- | Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs | 18 | ||||
-rw-r--r-- | Xamarin.Forms.Xaml/XmlName.cs | 1 |
2 files changed, 14 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. diff --git a/Xamarin.Forms.Xaml/XmlName.cs b/Xamarin.Forms.Xaml/XmlName.cs index e22a162d..09cf3bca 100644 --- a/Xamarin.Forms.Xaml/XmlName.cs +++ b/Xamarin.Forms.Xaml/XmlName.cs @@ -11,6 +11,7 @@ namespace Xamarin.Forms.Xaml public static readonly XmlName xTypeArguments = new XmlName("x", "TypeArguments"); public static readonly XmlName xArguments = new XmlName("x", "Arguments"); public static readonly XmlName xFactoryMethod = new XmlName("x", "xFactoryMethod"); + public static readonly XmlName Empty = new XmlName(); public string NamespaceURI { get; } |