本文整理汇总了C#中MobileServiceCollection.Move方法的典型用法代码示例。如果您正苦于以下问题:C# MobileServiceCollection.Move方法的具体用法?C# MobileServiceCollection.Move怎么用?C# MobileServiceCollection.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MobileServiceCollection
的用法示例。
在下文中一共展示了MobileServiceCollection.Move方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshChatItems
// Fetches the last chat conversation items from the cloud to be displayed on screen
private async void RefreshChatItems()
{
prgBusy.IsActive = true;
if (isLoggedin)
{
MobileServiceInvalidOperationException exception = null;
try
{
// The max number of items to retrieve from Azure Mobile Services
// Note that N CANNOT be greater than 50, we'd have to use paging for more
int n = 20;
// This code refreshes the entries in the list view by querying the ChatItems table.
// We only want the last N members, so we have to sort by descending order and request the first N
items = await chatTable.OrderByDescending(chatitem => chatitem.TimeStamp).Take(n).ToCollectionAsync();
// But now we need to reverse the order again so the last item is always at the bottom of the list, not the top
// Unfortunately, both of these methods are unsupported on a Mobile Service Collection
// items.Reverse<ChatItem>();
// items.OrderBy(chatitem => chatitem.TimeStamp);
// Let's get creative and manually invert the order of the items by moving them one by one
// Since there cannot be more than 50 items, this is not an unreasonable technique to use
if (items.Count > 0)
{
if (items.Count < n) { n = items.Count; }
for (int i = 0; i < (n - 1); i++)
{
items.Move(0, n - i - 1);
}
}
items.CollectionChanged += (s, args) => ScrollDown();
ScrollDown();
}
catch (MobileServiceInvalidOperationException e)
{
exception = e;
}
if (exception != null)
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
new MessageDialog(exception.Message, "Error loading items").ShowAsync();
});
}
else
{
ListItems.ItemsSource = items;
}
}
prgBusy.IsActive = false;
}