Project Description
SPListConfiguration is a SharePoint feature that developers can use to configure their SharePoint lists using XML and without the need of writing .NET code.

SPListConfiguration can be used for many different purposes. For example, you can use it to set most of the properties for the SPList object that references your list or to stop inheriting permissions from the parent web. You can even use it to add properties to the property bag of the list root folder.


For configuring a list using SPListConfiguration, you should specify the list name in the preoperty Key and the desired configuration settings in the property value as shown below :

<Properties>
<Property Key="Calendar" Value="Hidden,true;EnableVersioning,false;AddToPropertyBag,MyKey:MyValue"/>
<Property Key="Tasks" Value="BreakRoleInheritance,false;ReadSecurity,2"/>
</Properties>

The previous XML does the following on your behalf :
SPList.Hidden = true;
SPList.EnableVersioning= false;
SPList.BreakRoleInheritance(false);
SPList.ReadSecurity = 2;
And it also adds a property of name "MyKey" and value "MyValue" to the property bag of the SPlist root folder

Neat, eh ? This is the Reflection magic:)


SPListConfiguration can be used in two ways

1) From a site definition; in the <WebFeatures> element.

<WebFeatures>
<Feature ID="9697591b-c325-43e8-bf2f-3c33e05c59b4">
<Properties>
<Property Key="Calendar" Value="Hidden,true;EnableVersioning,false;AddToPropertyBag,MyKey:MyValue"/>
<Property Key="Tasks" Value="BreakRoleInheritance,false;ReadSecurity,2"/>
</Properties>
</Feature>
</WebFeatures>


2) Since the key component of this feature is its feature receiver which performs all the heavy lifting,
you can only use the feature receiver assembly and hook it up as a receiver for your features :

<Feature Id="ID of Your Feature"
Title="Countries List"
Description="A list that contains all the countries of the world"
Hidden="FALSE"
Scope="Web"
ReceiverAssembly="SPListConfigurationFeature, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=064ae22bb48e8f1b"
ReceiverClass="SPListConfigurationFeature.SPListConfigurationFeature"
xmlns="http://schemas.microsoft.com/sharepoint/">

<ElementManifests>
<!-- The countries List is created here -->
<ElementManifest Location="elements.xml"/>
</ElementManifests>

<Properties>
<!-- The countries List is configured here -->
<Property Key="Countries" Value="Hidden,true;BreakRoleInheritance,false"/>
</Properties>

</Feature>

Also keep in mind that you set any list properties of type String, Boolean or Int32 and this covers almost 95% of the available properties.

About Author
Ayman El-Hattab is a SharePoint Server MVP, Developer, Author & Speaker. Ayman is a faculty member at USPJ Academy where he teaches and facilitates SharePoint development courses. He is a public speaker for numerous user groups and offline communities, co-founder of SharePoint4Arabs.com, Egypt SharePoint User Group Leader and you will always find him active at MSDN and Technet forums.

Blog: http://www.aymanelhattab.com
Twitter: http://www.twitter.com/aymanelhattab

Last edited Jul 5, 2010 at 4:59 PM by sharepointholic, version 5