private Element createElementFromTemplateNoChildren(Template template, Template parentTemplate, AttributeCollection attributes, Element parent, params object[] inputs) { // If the parent template exists and defines a template with the same name as the new element, use that template instead of the given one. string identifierName = attributes?.GetAttributeOrDefault(nameAttributeName, (string)null); if (parentTemplate == null || identifierName == null || !parentTemplate.ChildrenByIdentifierName.TryGetValue(identifierName, out Template baseTemplate)) { baseTemplate = template; } // If attributes were given, combine them with the base template to make a unique template for this element. Template elementTemplate = attributes == null || attributes.Count == 0 ? baseTemplate.CreateCopy() : baseTemplate.CombineOver(attributes); // Get the style name from the element template attributes, if the style is missing, use the default. string styleName = elementTemplate.Attributes.GetAttributeOrDefault(styleAttributeName, string.Empty); Style style = string.IsNullOrWhiteSpace(styleName) ? styleManager.DefaultStyle.CreateCopy() : styleManager.GetStyleFromName(styleName); // Create the element. Element element = elementCache.CreateInstance(elementTemplate.ControllerName, serviceProvider, inputs); // Create the components, which internally initialises each one. Dictionary <Type, Component> components = componentManager.CreateComponents(elementTemplate.ComponentNames, element, inputs); // Initialise the element internally. element.internalOnCreated(root, this, styleManager, elementTemplate, parent == null ? ElementContainer : parent.ElementContainer, style, components); // Handle adding the element as tagged. addTaggedElement(element); // Initialise the element publicly. element.OnCreated(); return(element); }