[英]how to get a list of all content type groups using sharepoint client model in c#
I am developing a windows application that will allow user with an interface to create custom content-types. 我正在开发Windows应用程序,该应用程序将允许用户使用界面来创建自定义内容类型。 Everything is done except I want a dropdown list that will show all available content-types, just like the Sharepoint has.
一切都完成了,只不过我想要一个下拉列表,它将显示所有可用的内容类型,就像Sharepoint一样。
What I've achieved so far is: 到目前为止,我已经实现了:
var contentTypes = context.Web.AvailableContentTypes.Where(q => q.Group == "List content type");
What exactly I want is a dropdown where all the content-type groups are listed just like the way the above image has. 我想要的是一个下拉列表,其中列出了所有内容类型组,就像上面的图像一样。
Please suggest a way to get this done. 请提出一种解决方案。 Thanks in advance!
提前致谢!
You can try something like this: 您可以尝试如下操作:
ClientContext ctx = new ClientContext("URL");
SP.Web web = ctx.Web;
ctx.Load(web, w => w.AvailableContentTypes);
var cts = ctx.Web.AvailableContentTypes;
ctx.ExecuteQuery();
var groups = cts.ToList().Select(ct => ct.Group).Distinct();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.