共用方式為


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 命名空間