本文整理匯總了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));
}
}