ListCollectionView 类

定义

表示实现 IList 的集合的集合视图。Represents the collection view for collections that implement IList.

public ref class ListCollectionView : System::Windows::Data::CollectionView, System::Collections::IComparer, System::ComponentModel::ICollectionViewLiveShaping, System::ComponentModel::IEditableCollectionViewAddNewItem, System::ComponentModel::IItemProperties
public ref class ListCollectionView : System::Windows::Data::CollectionView, System::Collections::IComparer, System::ComponentModel::IEditableCollectionView, System::ComponentModel::IItemProperties
public ref class ListCollectionView : System::Windows::Data::CollectionView, System::Collections::IComparer, System::ComponentModel::IEditableCollectionViewAddNewItem, System::ComponentModel::IItemProperties
public class ListCollectionView : System.Windows.Data.CollectionView, System.Collections.IComparer, System.ComponentModel.ICollectionViewLiveShaping, System.ComponentModel.IEditableCollectionViewAddNewItem, System.ComponentModel.IItemProperties
public class ListCollectionView : System.Windows.Data.CollectionView, System.Collections.IComparer, System.ComponentModel.IEditableCollectionView, System.ComponentModel.IItemProperties
public class ListCollectionView : System.Windows.Data.CollectionView, System.Collections.IComparer, System.ComponentModel.IEditableCollectionViewAddNewItem, System.ComponentModel.IItemProperties
type ListCollectionView = class
    inherit CollectionView
    interface IComparer
    interface ICollectionViewLiveShaping
    interface IEditableCollectionView
    interface IEditableCollectionViewAddNewItem
    interface IItemProperties
type ListCollectionView = class
    inherit CollectionView
    interface IComparer
    interface IEditableCollectionView
    interface IItemProperties
type ListCollectionView = class
    inherit CollectionView
    interface IComparer
    interface IEditableCollectionViewAddNewItem
    interface IEditableCollectionView
    interface IItemProperties
type ListCollectionView = class
    inherit CollectionView
    interface IComparer
    interface IEditableCollectionViewAddNewItem
    interface IEditableCollectionView
    interface ICollectionViewLiveShaping
    interface IItemProperties
Public Class ListCollectionView
Inherits CollectionView
Implements ICollectionViewLiveShaping, IComparer, IEditableCollectionViewAddNewItem, IItemProperties
Public Class ListCollectionView
Inherits CollectionView
Implements IComparer, IEditableCollectionView, IItemProperties
Public Class ListCollectionView
Inherits CollectionView
Implements IComparer, IEditableCollectionViewAddNewItem, IItemProperties
继承
实现

注解

绑定到数据集合时,可能需要对数据进行排序、筛选或分组。When you bind to a data collection, you may want to sort, filter, or group the data. 为此,请使用集合视图。To do that, you use collection views. 您可以将 CollectionView 用作绑定源集合顶部的层,以允许您根据排序、筛选和组查询导航和显示源集合,所有这些操作都无需处理基础源集合本身。You can think of a CollectionView as the layer on top of the binding source collection that allows you to navigate and display the source collection based on sort, filter, and group queries, all without having to manipulate the underlying source collection itself. 如果源集合实现 INotifyCollectionChanged 接口,则 CollectionChanged 事件引发的更改会传播到视图。If the source collection implements the INotifyCollectionChanged interface, the changes raised by the CollectionChanged event are propagated to the views.

所有集合都具有默认值 CollectionViewAll collections have a default CollectionView. 对于实现的所有集合 IListListCollectionView 对象是默认视图对象。For all collections implementing IList, the ListCollectionView object is the default view object. BindingListCollectionView是用于实现的集合的集合视图类 IBindingListThe BindingListCollectionView is the collection view class used for collections that implement IBindingList. 若要获取默认视图,请使用 GetDefaultView 方法。To get the default view, you use the GetDefaultView method. 有关示例,请参阅 如何:获取数据集合的默认视图For an example, see How to: Get the Default View of a Data Collection.

有关集合视图的详细信息,请参阅 数据绑定概述For more information about collection views, see Data Binding Overview.

构造函数

ListCollectionView(IList)

使用所提供的实现 ListCollectionView 的集合来初始化 IList 类的新实例。Initializes a new instance of the ListCollectionView class, using a supplied collection that implements IList.

属性

ActiveComparer

获取或设置在排序时使用的当前活动比较器。Gets or sets the current active comparer that is used in sorting.

ActiveFilter

获取或设置当前活动的 Filter 回调。Gets or sets the current active Filter callback.

AllowsCrossThreadChanges

获取指示创建的 CollectionView 线程能更改 SourceCollection 的值。Gets a value that indicates whether a thread other than the one that created the CollectionView can change the SourceCollection.

(继承自 CollectionView)
CanAddNew

获取一个值,该值指示是否可以将新项添加到集合中。Gets a value that indicates whether a new item can be added to the collection.

CanAddNewItem

获取一个值,该值指示是否可以向集合中添加指定的对象。Gets a value that indicates whether a specified object can be added to the collection.

CanCancelEdit

获取一个值,该值指示集合视图是否可以放弃挂起的更改并还原所编辑对象的原始值。Gets a value that indicates whether the collection view can discard pending changes and restore the original values of an edited object.

CanChangeLiveFiltering

获取一个值,该值指示集合视图是否支持打开或关闭实时筛选数据。Gets a value that indicates whether the collection view supports turning filtering data in real time on or off.

CanChangeLiveGrouping

获取一个值,该值指示集合视图是否支持在真实时间中打开或关闭分组数据。Gets a value that indicates whether the collection view supports turning grouping data in real time on or off.

CanChangeLiveSorting

获取一个值,该值指示集合视图是否支持在真实时间中打开或关闭排序数据。Gets a value that indicates whether the collection view supports turning sorting data in real time on or off.

CanFilter

获取一个值,该值指示视图是否支持基于回调的筛选。Gets a value that indicates whether the view supports callback-based filtering.

CanGroup

获取一个值,该值指示集合视图是否支持分组。Gets a value that indicates whether the collection view supports grouping.

CanRemove

获取一个值,该值指示是否可以从集合中移除项。Gets a value that indicates whether an item can be removed from the collection.

CanSort

获取一个值,该值指示集合视图是否支持排序。Gets a value that indicates whether the collection view supports sorting.

Comparer

返回可用于比较视图中的项的对象。Returns an object that you can use to compare items in the view.

(继承自 CollectionView)
Count

获取记录的估计数量。Gets the estimated number of records.

Culture

获取或设置排序期间使用的区域性信息。Gets or sets the culture information to use during sorting.

(继承自 CollectionView)
CurrentAddItem

获取当前添加事务过程中正在添加的项。Gets the item that is being added during the current add transaction.

CurrentEditItem

获取集合中正在编辑的项。Gets the item in the collection that is being edited.

CurrentItem

获取视图中的当前项。Gets the current item in the view.

(继承自 CollectionView)
CurrentPosition

获取 CurrentItem 在(可能经过排序和筛选)视图中的序号位置。Gets the ordinal position of the CurrentItem within the (optionally sorted and filtered) view.

(继承自 CollectionView)
CustomSort

获取或设置一个实现 IComparer 的自定义对象,用于在视图中对项进行排序。Gets or sets a custom object that implements IComparer to sort items in the view.

Dispatcher

获取与此 Dispatcher 关联的 DispatcherObjectGets the Dispatcher this DispatcherObject is associated with.

(继承自 DispatcherObject)
Filter

获取或设置用于确定某个项是否适合包含在视图中的方法。Gets or sets a method that is used to determine whether an item is suitable for inclusion in the view.

GroupBySelector

获取或设置一个委托,用于将 GroupDescription 选作父组及其级别的功能。Gets or sets a delegate to select the GroupDescription as a function of the parent group and its level.

GroupDescriptions

获取 GroupDescription 对象的集合,这些对象描述集合中的项在视图中的分组方式。Gets a collection of GroupDescription objects that describe how the items in the collection are grouped in the view.

Groups

获取顶级组。Gets the top-level groups.

InternalCount

获取 InternalList 中记录的数量。Gets the number of records in the InternalList.

InternalList

获取经过筛选和排序的项列表。Gets the filtered and sorted list of items.

IsAddingNew

获取一个值,该值指示是否正在执行添加事务。Gets a value that indicates whether an add transaction is in progress.

IsCurrentAfterLast

获取一个值,该值指示视图的 CurrentItem 是否超出集合的末尾。Gets a value that indicates whether the CurrentItem of the view is beyond the end of the collection.

(继承自 CollectionView)
IsCurrentBeforeFirst

获取一个值,该值指示视图的 CurrentItem 是否在集合开头之前。Gets a value that indicates whether the CurrentItem of the view is before the beginning of the collection.

(继承自 CollectionView)
IsCurrentInSync

获取一个值,该值指示 CurrentItem 是否位于 CurrentPositionGets a value that indicates whether the CurrentItem is at the CurrentPosition.

(继承自 CollectionView)
IsDataInGroupOrder

获取或设置一个值,该值指示项列表在应用排序功能和筛选器(如果有)后是否已处于可以进行分组的正确顺序。Gets or sets a value that indicates whether the list of items (after applying the sort and filters, if any) is already in the correct order for grouping.

IsDynamic

获取一个值,该值指示基础集合是否提供更改通知。Gets a value that indicates whether the underlying collection provides change notifications.

(继承自 CollectionView)
IsEditingItem

获取一个值,该值指示是否正在执行编辑事务。Gets a value that indicates whether an edit transaction is in progress.

IsEmpty

返回一个值,该值指示最终的(已筛选)视图是否为空。Returns a value that indicates whether the resulting (filtered) view is empty.

IsGrouping

获取一个值,该值指示视图中是否有组。Gets a value that indicates whether there are groups in the view.

IsInUse

获取指示所有对象是否支持此 CollectionView 事件的值。Gets a value that indicates whether any object is subscribing to the events of this CollectionView.

(继承自 CollectionView)
IsLiveFiltering

获取或设置一个值,该值指示是否启用实时筛选数据。Gets or sets a value that indicates whether filtering data in real time is enabled.

IsLiveGrouping

获取或设置一个值,该值指示是否启用实时数据分组。Gets or sets a value that indicates whether grouping data in real time is enabled.

IsLiveSorting

获取或设置一个值,该值指示是否启用实时排序。Gets or sets a value that indicates whether sorting in real time is enabled.

IsRefreshDeferred

获取一个值,该值指示是否有某个未完成的 DeferRefresh() 正在运行。Gets a value that indicates whether there is an outstanding DeferRefresh() in use.

(继承自 CollectionView)
ItemProperties

获取一个对象集合,该集合描述集合中项的属性。Gets a collection of objects that describes the properties of the items in the collection.

LiveFilteringProperties

获取在真实时间中参与筛选数据的属性的字符集合。Gets a collection of strings that specify the properties that participate in filtering data in real time.

LiveGroupingProperties

获取在真实时间中参与分组数据的属性的字符集合。Gets a collection of strings that specify the properties that participate in grouping data in real time.

LiveSortingProperties

获取在真实时间中参与排序数据的属性的字符集合。Gets a collection of strings that specify the properties that participate in sorting data in real time.

NeedsRefresh

获取一个值,该值指示视图是否需要刷新。Gets a value that indicates whether the view needs to be refreshed.

(继承自 CollectionView)
NewItemPlaceholderPosition

获取或设置新项占位符在 ListCollectionView 中的位置。Gets or sets the position of the new item placeholder in the ListCollectionView.

SortDescriptions

获取 SortDescription 对象的集合,该集合描述集合中的项在视图中的排序方式。Gets a collection of SortDescription objects that describes how the items in the collection are sorted in the view.

SourceCollection

返回未筛选的基础集合。Returns the underlying unfiltered collection.

(继承自 CollectionView)
UpdatedOutsideDispatcher

获取一个值,该值指示是否有必要更新更改日志,因为在 CollectionChanged 没有首先进入用户界面 (UI) 线程调度程序的情况下,已在其他线程上收到通知。Gets a value that indicates whether it has been necessary to update the change log because a CollectionChanged notification has been received on a different thread without first entering the user interface (UI) thread dispatcher.

(继承自 CollectionView)
UsesLocalArray

获取一个值,该值指示排序和筛选是否需要数据的私有副本。Gets a value that indicates whether a private copy of the data is needed for sorting and filtering.

方法

AddNew()

开始添加事务并返回挂起的新项。Starts an add transaction and returns the pending new item.

AddNewItem(Object)

将指定的对象添加到集合。Adds the specified object to the collection.

CancelEdit()

结束编辑事务,并还原项的原始值(如有可能)。Ends the edit transaction, and if possible, restores the original value to the item.

CancelNew()

结束添加事务并放弃挂起的新项。Ends the add transaction and discards the pending new item.

CheckAccess()

确定调用线程是否可以访问此 DispatcherObjectDetermines whether the calling thread has access to this DispatcherObject.

(继承自 DispatcherObject)
ClearChangeLog()
已过时。

从更改日志中清除所有挂起的更改。Clears any pending changes from the change log.

(继承自 CollectionView)
ClearPendingChanges()

清除未处理更改为集合。Clears unprocessed changed to the collection.

(继承自 CollectionView)
CommitEdit()

结束编辑事务并保存挂起的更改。Ends the edit transaction and saves the pending changes.

CommitNew()

结束添加事务并保存挂起的新项。Ends the add transaction and saves the pending new item.

Compare(Object, Object)

比较两个对象并返回一个值,指示一个对象是小于、等于还是大于另一个对象。Compares two objects and returns a value that indicates whether one is less than, equal to, or greater than the other.

Contains(Object)

返回一个值,该值指示给定项是否属于集合视图。Returns a value that indicates whether a given item belongs to the collection view.

DeferRefresh()

进入延迟循环,该循环可用于将更改合并到视图并延迟自动刷新。Enters a defer cycle that you can use to merge changes to the view and delay automatic refresh.

(继承自 CollectionView)
DetachFromSourceCollection()

CollectionView 中移除对基础集合的引用。Removes the reference to the underlying collection from the CollectionView.

(继承自 CollectionView)
EditItem(Object)

开始指定项的编辑事务。Begins an edit transaction of the specified item.

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetEnumerator()

返回可用于枚举视图中的项的对象。Returns an object that you can use to enumerate the items in the view.

GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetItemAt(Int32)

检索位于视图中指定位置的项。Retrieves the item at the specified position in the view.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IndexOf(Object)

返回给定数据项在集合中所在位置的索引,如果该项的索引未知,则返回 -1。Returns the index where the given data item belongs in the collection, or -1 if the index of that item is unknown.

InternalContains(Object)

返回一个值,该值指示 InternalList 是否包含此项。Return a value that indicates whether the InternalList contains the item.

InternalGetEnumerator()

返回 InternalList 的一个枚举数。Returns an enumerator for the InternalList.

InternalIndexOf(Object)

返回指定项在 InternalList 中的索引。Returns the index of the specified item in the InternalList.

InternalItemAt(Int32)

返回 InternalList 中给定索引处的项。Returns the item at the given index in the InternalList.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MoveCurrentTo(Object)

将指定项设置为视图中的 CurrentItemSets the specified item to be the CurrentItem in the view.

(继承自 CollectionView)
MoveCurrentToFirst()

将视图中的第一项设置为 CurrentItemSets the first item in the view as the CurrentItem.

(继承自 CollectionView)
MoveCurrentToLast()

将视图中的最后一项设置为 CurrentItemSets the last item in the view as the CurrentItem.

(继承自 CollectionView)
MoveCurrentToNext()

将视图中位于 CurrentItem 之后的项设置为 CurrentItemSets the item after the CurrentItem in the view as the CurrentItem.

(继承自 CollectionView)
MoveCurrentToPosition(Int32)

将位于指定索引位置的项设置为视图中的 CurrentItemSets the item at the specified index to be the CurrentItem in the view.

MoveCurrentToPrevious()

将视图中位于 CurrentItem 之前的项设置为 CurrentItemSets the item before the CurrentItem in the view as the CurrentItem.

(继承自 CollectionView)
OKToChangeCurrent()

返回一个值,该值指示视图是否可以更改作为 CurrentItem 的项。Returns a value that indicates whether the view can change which item is the CurrentItem.

(继承自 CollectionView)
OnAllowsCrossThreadChangesChanged()

AllowsCrossThreadChanges 属性更改时发生。Occurs when the AllowsCrossThreadChanges property changes.

OnAllowsCrossThreadChangesChanged()

AllowsCrossThreadChanges 属性更改时发生。Occurs when the AllowsCrossThreadChanges property changes.

(继承自 CollectionView)
OnBeginChangeLogging(NotifyCollectionChangedEventArgs)
已过时。

由基类调用,用于通知派生类已将 CollectionChanged 事件发送到消息队列。Called by the base class to notify the derived class that a CollectionChanged event has been posted to the message queue.

OnCollectionChanged(NotifyCollectionChangedEventArgs)

引发 CollectionChanged 事件。Raises the CollectionChanged event.

(继承自 CollectionView)
OnCollectionChanged(Object, NotifyCollectionChangedEventArgs)

引发 CollectionChanged 事件。Raises the CollectionChanged event.

(继承自 CollectionView)
OnCurrentChanged()

引发 CurrentChanged 事件。Raises the CurrentChanged event.

(继承自 CollectionView)
OnCurrentChanging()

引发一个不可取消的 CurrentChanging 事件。Raises a CurrentChanging event that is not cancelable.

(继承自 CollectionView)
OnCurrentChanging(CurrentChangingEventArgs)

用指定的参数引发 CurrentChanging 事件。Raises the CurrentChanging event with the specified arguments.

(继承自 CollectionView)
OnPropertyChanged(PropertyChangedEventArgs)

用指定的参数引发 PropertyChanged 事件。Raises the PropertyChanged event using the specified arguments.

(继承自 CollectionView)
PassesFilter(Object)

返回一个值,该值指示基础集合中的指定项是否属于视图。Returns a value that indicates whether the specified item in the underlying collection belongs to the view.

ProcessCollectionChanged(NotifyCollectionChangedEventArgs)

处理 CollectionChanged 事件。Handles CollectionChanged events.

ProcessPendingChanges()

确保此集合的所有待定更改都已被提交。Ensures that all pending changes to the collection have been committed.

(继承自 CollectionView)
Refresh()

重新创建视图。Re-creates the view.

(继承自 CollectionView)
RefreshOrDefer()

刷新视图或指定视图在延迟循环完成后需要刷新。Refreshes the view or specifies that the view needs to be refreshed when the defer cycle completes.

(继承自 CollectionView)
RefreshOverride()

重新创建该视图。Recreates the view.

Remove(Object)

从集合中移除指定的项。Removes the specified item from the collection.

RemoveAt(Int32)

从集合中删除指定位置的项。Removes the item at the specified position from the collection.

SetCurrent(Object, Int32)

将指定项和索引设置为 CurrentItemCurrentPosition 属性的值。Sets the specified item and index as the values of the CurrentItem and CurrentPosition properties.

(继承自 CollectionView)
SetCurrent(Object, Int32, Int32)

将指定项和索引设置为 CurrentItemCurrentPosition 属性的值。Sets the specified item and index as the values of the CurrentItem and CurrentPosition properties. 可以从派生类的构造函数中调用此方法。This method can be called from a constructor of a derived class.

(继承自 CollectionView)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)
VerifyAccess()

强制调用线程具有此 DispatcherObject 的访问权限。Enforces that the calling thread has access to this DispatcherObject.

(继承自 DispatcherObject)

事件

CollectionChanged

在更改树时发生。Occurs when the view has changed.

(继承自 CollectionView)
CurrentChanged

CurrentItem 更改后发生。Occurs after the CurrentItem has changed.

(继承自 CollectionView)
CurrentChanging

CurrentItem 正在更改时发生。Occurs when the CurrentItem is changing.

(继承自 CollectionView)
PropertyChanged

在属性值更改时发生。Occurs when a property value has changed.

(继承自 CollectionView)

显式接口实现

IComparer.Compare(Object, Object)

此成员支持 Windows Presentation Foundation (WPF) 基础结构,不应在代码中直接使用。This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

IEnumerable.GetEnumerator()

返回可用于枚举视图中的项的 IEnumerator 对象。Returns an IEnumerator object that you can use to enumerate the items in the view.

(继承自 CollectionView)
INotifyCollectionChanged.CollectionChanged

在更改树时发生。Occurs when the view has changed.

(继承自 CollectionView)
INotifyPropertyChanged.PropertyChanged

在属性值更改时发生。Occurs when a property value changes.

(继承自 CollectionView)

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于