Specifies a calling contract for collection views that support incremental loading.
Syntax
Attributes
- GuidAttribute("7f5ee992-7694-4e6c-a51b-e34bf43de743")
- VersionAttribute(NTDDI_WIN8)
- WebHostHiddenAttribute()
Members
The ISupportIncrementalLoading interface has these types of members:
Methods
The ISupportIncrementalLoading interface has these methods. It also inherits methods from the Object class.
| Method | Description |
|---|---|
| LoadMoreItemsAsync | Initializes incremental loading from the view. |
Properties
The ISupportIncrementalLoading interface has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Gets a sentinel value that supports incremental loading implementations. |
Examples
The following code example demonstrates how to implement this interface. For the complete code listing, see the XAML data Binding sample.
#region ISupportIncrementalLoading public bool HasMoreItems { get { return HasMoreItemsOverride(); } } public Windows.Foundation.IAsyncOperation<LoadMoreItemsResult> LoadMoreItemsAsync(uint count) { if (_busy) { throw new InvalidOperationException("Only one operation in flight at a time"); } _busy = true; return AsyncInfo.Run((c) => LoadMoreItemsAsync(c, count)); } #endregion #region INotifyCollectionChanged public event NotifyCollectionChangedEventHandler CollectionChanged; #endregion #region Private methods async Task<LoadMoreItemsResult> LoadMoreItemsAsync(CancellationToken c, uint count) { try { var items = await LoadMoreItemsOverrideAsync(c, count); var baseIndex = _storage.Count; _storage.AddRange(items); // Now notify of the new items NotifyOfInsertedItems(baseIndex, items.Count); return new LoadMoreItemsResult { Count = (uint)items.Count }; } finally { _busy = false; } } void NotifyOfInsertedItems(int baseIndex, int count) { if (CollectionChanged == null) { return; } for (int i = 0; i < count; i++) { var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, _storage[i + baseIndex], i + baseIndex); CollectionChanged(this, args); } } #endregion #region Overridable methods protected abstract Task<IList<object>> LoadMoreItemsOverrideAsync(CancellationToken c, uint count); protected abstract bool HasMoreItemsOverride(); #endregion #region State List<object> _storage = new List<object>(); bool _busy = false; #endregion
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 12/4/2012