When using SPWeb.GetCatalog(SPListTemplateType.WebPartCatalog), it returns an SPList which of course contains a SPListItemCollection of the web parts in the web part gallery.

When looping through the items, is there any easy way to get properties of the web parts? Such as AllowClose, CatalogIconImageUrl, etc...

I know I can probably accomplish this using the listItem.OpenBinaryStream etc and loading the xml of the .webpart file, but I wondered if there was an easier way to do this.

1 Answer 1


Nope. If you load the webparts like that all you get are SPListItems (which are from the gallery) and not SPWebPart objects (which you'll realistically only get from instances that exist on a page - or from loading in via an SPWebPartManager object [and even then loading from the gallery, you would need to extract the XML in exactly the same way anyway]). You'll have to do SPListItem.File.OpenBinaryStream() and fire it into an XmlReader or XDocument object for easier parsing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.