private void itemRetrive()
{
string siteUrl = "http://Site";
clientContext = new ClientContext(siteUrl);
oList = clientContext.Web.Lists.GetByTitle("Demo");
ListItemCollectionPosition itemPosition = null;
CamlQuery camlQuery = new CamlQuery();
camlQuery.ListItemCollectionPosition = itemPosition;
camlQuery.ViewXml =
@"<View>
<ViewFields>
<FieldRef Name='Title'/>
<FieldRef Name='Name'/>
</ViewFields>
<RowLimit>10</RowLimit>
</View>";
listItems = oList.GetItems(camlQuery);
clientContext.Load(oList);
clientContext.Load(listItems);
clientContext.ExecuteQueryAsync(QuerySucceeded, QueryFailed);
}
private void QuerySucceeded(object sender, ClientRequestSucceededEventArgs args)
{
this.Dispatcher.BeginInvoke(() =>
{
foreach (ListItem listItem in listItems)
{
listBox1.Items.Add(listItem["Title"].ToString());
}
});
}
private void QueryFailed(object sender, ClientRequestFailedEventArgs args)
{
Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("");
});
}
No comments:
Post a Comment