private static void AddControl(CommandBarControls parentControls, XmlNode xmlNode, GetImageDelegate getImage) { if (xmlNode.Name == "popup") { string controlName = xmlNode.Attributes["caption"].Value; object before = ReadControlBeforeAttribute(xmlNode); CommandBarPopup newPopup = parentControls.AddPopup(controlName, before); ApplyControlAttributes(newPopup, xmlNode, getImage); AddControls(newPopup.Controls, xmlNode.ChildNodes, getImage); } else if (xmlNode.Name == "button") { object before = ReadControlBeforeAttribute(xmlNode); CommandBarButton newButton = parentControls.AddButton(before); ApplyControlAttributes(newButton, xmlNode, getImage); } }