View Class

Specifies a list view.

Namespace:  Microsoft.SharePoint.Client
Assemblies:   Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

[ScriptTypeAttribute("SP.View", ServerTypeId = "{2399f45d-1784-4965-9a5f-a3415790a0d0}")]
public class View : ClientObject

This code example orders the items on the Tasks list of the specified site in descending alphabetic order.

using System;
using Microsoft.SharePoint.Client;

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

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

            List targetList = site.Lists.GetByTitle("Tasks");
            ViewCollection collView = targetList.Views;
            View targetView = collView.GetByTitle("All Tasks");
            string strQuery = "<OrderBy><FieldRef Name=\'Title\' Ascending=\'False\' /></OrderBy>";
            targetView.ViewQuery = strQuery;


            Console.WriteLine("Tasks list ordered in descending alphabetic order.");

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.