NavigationNodeCollection.Add 方法

创建导航节点对象并将其添加到集合。

命名空间:  Microsoft.SharePoint.Client
程序集:   Microsoft.SharePoint.Client.Silverlight(位于 Microsoft.SharePoint.Client.Silverlight.dll 中);  Microsoft.SharePoint.Client.Phone(位于 Microsoft.SharePoint.Client.Phone.dll 中)  Microsoft.SharePoint.Client(位于 Microsoft.SharePoint.Client.dll 中)

语法

声明
Public Function Add ( _
    parameters As NavigationNodeCreationInformation _
) As NavigationNode
用法
Dim instance As NavigationNodeCollection
Dim parameters As NavigationNodeCreationInformation
Dim returnValue As NavigationNode

returnValue = instance.Add(parameters)
public NavigationNode Add(
    NavigationNodeCreationInformation parameters
)

参数

返回值

类型:Microsoft.SharePoint.Client.NavigationNode
返回表示创建导航节点对象的NavigationNode实例,并将其添加到集合。

示例

此代码示例将节点添加到指定的网站的快速启动区域,并显示当前的快速启动节点。

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
{
    class NavigationNodeCollection_AddExample
    {
        static void Main()
        {
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;

            // Get the Quick Launch navigation node collection.
            NavigationNodeCollection collQuickLaunchNode = site.Navigation.QuickLaunch;

            // Set properties for a new navigation node.
            NavigationNodeCreationInformation ciNavicationNode = new NavigationNodeCreationInformation();
            ciNavicationNode.Title = "New Node";
            ciNavicationNode.Url = "https://localhost";
            // Create node as the last node in the collection.
            ciNavicationNode.AsLastNode = true;
            collQuickLaunchNode.Add(ciNavicationNode);

            clientContext.Load(collQuickLaunchNode);
            clientContext.ExecuteQuery();

            Console.WriteLine("Current nodes:\n");
            foreach (NavigationNode navNode in collQuickLaunchNode)
               Console.WriteLine(navNode.Title);
        }
    }
}

另请参阅

引用

NavigationNodeCollection 类

NavigationNodeCollection 成员

Microsoft.SharePoint.Client 命名空间