protected void UpdateData()
        {
            IncrementState();

            MarkExistingItemsAsStale();

            _fetchedPages.Clear();
            _requestedPages.Clear();

            UpdateCount();

            var queryItemVisibilityArgs = new QueryItemVisibilityEventArgs();

            OnQueryItemVisibility(queryItemVisibilityArgs);

            if (queryItemVisibilityArgs.FirstVisibleIndex.HasValue)
            {
                var firstVisiblePage = queryItemVisibilityArgs.FirstVisibleIndex.Value / _pageSize;
                var lastVisiblePage  = queryItemVisibilityArgs.LastVisibleIndex.Value / _pageSize;

                int numberOfVisiblePages = lastVisiblePage - firstVisiblePage + 1;
                EnsurePageCacheSize(numberOfVisiblePages);

                for (int i = firstVisiblePage; i <= lastVisiblePage; i++)
                {
                    BeginGetPage(i);
                }
            }
            else
            {
                // in this case we have no way of knowing which items are currently visible,
                // so we signal a collection reset, and wait to see which pages are requested by the UI
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
            }
        }
Exemplo n.º 2
0
        protected void OnQueryItemVisibility(QueryItemVisibilityEventArgs e)
        {
            EventHandler <QueryItemVisibilityEventArgs> handler = QueryItemVisibility;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        private void HandleQueryItemVisibility(object sender, QueryItemVisibilityEventArgs e)
        {
            var wrapPanel = AssociatedObject.GetItemsHost() as VirtualizingWrapPanel;

            if (wrapPanel != null)
            {
                var range = wrapPanel.GetVisibleItemsRange();
                e.SetVisibleRange(range.FirstRealizedItemIndex, range.LastRealizedItemIndex);
            }
        }