I was working on a project and I had custom content types defined in a feature. These content types had document templates, and I wanted to control the Document Information Panel (DIP) when a document is opened in Word.
The following code snippet takes an SPContentType object and adds a custom XSN element to the content types XmlDocuments collection. Setting the openByDefault value to “True” will force the DIP to open when the document loads. I use a FeatureReceiver to run this code against a newly provisioned Content Type.
public static void ConfigureContentTypes(SPContentType ct)
{
XmlDocument doc = GetCustomXsnDocument();
ct.XmlDocuments.Add(doc);
ct.Update(true);
}
private static XmlDocument GetCustomXsnDocument()
{
XmlDocument doc = new XmlDocument();
string xml = "<customXsn xmlns=\"http://schemas.microsoft.com/office/2006/metadata/customXsn\"><xsnLocation></xsnLocation><cached>True</cached><openByDefault>True</openByDefault><xsnScope></xsnScope></customXsn>";
doc.LoadXml(xml);
return doc;
}
You can find information about the child CustomXsn elements on this MSDN link: Content Type Document Information Panel Schema
Hope this helps.