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