コード例 #1
0
        void item_LayoutStateChangeCompleted(object sender, LayoutStateChangeEventArgs e)
        {
            if (e.NewState == LayoutState.Unloaded)
            {
                var item = sender as AnimatedLayoutControl;
                item.LayoutStateChangeCompleted -= new EventHandler <LayoutStateChangeEventArgs>(item_LayoutStateChangeCompleted);

                BaseItemsSource.Clear();
                VisualItems.Clear();

                isUnloading = false;
                var itemsToAdd = NewRequestedItems.ToArray();
                NewRequestedItems.Clear();
                foreach (var newItem in itemsToAdd)
                {
                    BaseItemsSource.Add(newItem);
                }
            }
        }
コード例 #2
0
        void ObservableItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (var item in e.NewItems)
                {
                    if (isUnloading)
                    {
                        NewRequestedItems.Add(item);
                    }
                    else
                    {
                        BaseItemsSource.Add(item);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                if (!IsVisible)
                {
                    BaseItemsSource.Clear();
                    VisualItems.Clear();
                    isUnloading = false;
                }
                else if (VisualItems.Count > 0)
                {
                    isUnloading = true;
                    AnimatedLayoutControl lastItem = null;
                    foreach (var item in VisualItems)
                    {
                        if ((lastItem == null) || (item.BeginTime > lastItem.BeginTime))
                        {
                            lastItem = item;
                        }
                        item.LayoutState = LayoutState.Unloaded;
                    }

                    lastItem.LayoutStateChangeCompleted += new EventHandler <LayoutStateChangeEventArgs>(item_LayoutStateChangeCompleted);
                }
                break;
            }
        }