我创建了一个 SP.List 项目“lst”。 我也:
lst.ContentTypesEnabled = true;
lst.Update();
clientContext.ExecuteQuery();
我已经搜索了AvailableContentTypes并找到了我想要添加到lst中的内容。 我然后:
SP.ContentTypeCollection lstTypeCollection = lst.ContentTypes;
...现在我被困住了。
lstTypeCollection.Add()
需要一个 ContentTypeCreationInformation
对象
那时我在黑暗中徘徊。
你能透露一下吗?提前致谢:-)
最佳答案
使用ContentTypeCollection.AddExistingContentType method要在列表中添加现有的内容类型。
示例
var list = context.Web.Lists.GetByTitle(listTitle);
list.ContentTypesEnabled = true;
var contentType = context.Site.RootWeb.ContentTypes.GetById("0x0120"); //get Folder content type
list.ContentTypes.AddExistingContentType(contentType);
context.ExecuteQuery();
关于sharepoint - 客户端对象模型将内容类型添加到列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24310248/