當前位置: 首頁>>代碼示例>>C#>>正文


C# CollectionView.DeferRefresh方法代碼示例

本文整理匯總了C#中CollectionView.DeferRefresh方法的典型用法代碼示例。如果您正苦於以下問題:C# CollectionView.DeferRefresh方法的具體用法?C# CollectionView.DeferRefresh怎麽用?C# CollectionView.DeferRefresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CollectionView的用法示例。


在下文中一共展示了CollectionView.DeferRefresh方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetCollectionView

        // Change the collection view in use, unhook/hook event handlers 
        void SetCollectionView(CollectionView view)
        {
            if (_collectionView == view)
                return; 

            if (_collectionView != null) 
            { 
                // Unhook events first, to avoid unnecessary refresh while it is still the active view.
                if (!_isInitializing) 
                    UnhookCollectionView(_collectionView);

                if (IsRefreshDeferred)  // we've been deferring refresh on the _collectionView
                { 
                    // end defer refresh on the _collectionView that we're letting go
                    _deferInnerRefresh.Dispose(); 
                    _deferInnerRefresh = null; 
                }
            } 

            bool raiseReset = false;
            _collectionView = view;
            InvalidateEnumerableWrapper(); 

            if (_collectionView != null) 
            { 
                _deferInnerRefresh = _collectionView.DeferRefresh();
 
                ApplySortFilterAndGroup();

                // delay event hook-up when initializing.  see BeginInit() and EndInit().
                if (!_isInitializing) 
                    HookCollectionView(_collectionView);
 
                if (!IsRefreshDeferred) 
                {
                    // make sure we get at least one refresh 
                    raiseReset = !_collectionView.NeedsRefresh;

                    _deferInnerRefresh.Dispose();    // This fires refresh event that should reach ItemsControl listeners
                    _deferInnerRefresh = null; 
                }
                // when refresh is deferred, we hold on to the inner DeferRefresh until EndDefer() 
            } 
            else    // ItemsSource binding returned null
            { 
                if (!IsRefreshDeferred)
                {
                    raiseReset = true;
                } 
            }
 
            if (raiseReset) 
            {
                // notify listeners that the view is changed 
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
            }
        }
開發者ID:sjyanxin,項目名稱:WPFSource,代碼行數:58,代碼來源:ItemCollection.cs


注:本文中的CollectionView.DeferRefresh方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。