Skip to main content

DataGridCollectionView Class

DataGrid-readable view over an IEnumerable.

Definition

Namespace: Avalonia.Collections
Assembly: Avalonia.Controls.DataGrid (in Avalonia.Controls.DataGrid.dll)

public sealed class DataGridCollectionView : IDataGridCollectionView, 
IEnumerable, INotifyCollectionChanged, IList, ICollection, INotifyPropertyChanged
View Source
InheritanceObject → DataGridCollectionView
ImplementsIDataGridCollectionView, ICollection, IEnumerable, IList, INotifyCollectionChanged, INotifyPropertyChanged

Constructors

DataGridCollectionView(IEnumerable)Helper constructor that sets default values for isDataSorted and isDataInGroupOrder.
DataGridCollectionView(IEnumerable, Boolean, Boolean)Initializes a new instance of the DataGridCollectionView class.

Properties

CanAddNewGets a value indicating whether the view supports AddNew.
CanCancelEditGets a value indicating whether the view supports the notion of "pending changes" on the current edit item. This may vary, depending on the view and the particular item. For example, a view might return true if the current edit item implements IEditableObject, or if the view has special knowledge about the item that it can use to support rollback of pending changes.
CanChangePageGets a value indicating whether the PageIndex value is allowed to change or not.
CanFilterGets a value indicating whether we support filtering with this ICollectionView.
CanGroupGets a value indicating whether this view supports grouping. When this returns false, the rest of the interface is ignored.
CanRemoveGets a value indicating whether the view supports Remove and RemoveAt.
CanSortGets a value indicating whether we support sorting with this ICollectionView.
CountGets the number of records in the view after filtering, sorting, and paging.
CultureGets or sets Culture to use during sorting.
CurrentAddItemGets the new item when an AddNew transaction is in progress Otherwise it returns null.
CurrentEditItemGets the affected item when an EditItem transaction is in progress Otherwise it returns null.
CurrentItemGets the "current item" for this view
CurrentPositionGets the ordinal position of the CurrentItem within the (optionally sorted and filtered) view.
FilterGets or sets the Filter, which is a callback set by the consumer of the ICollectionView and used by the implementation of the ICollectionView to determine if an item is suitable for inclusion in the view.
GroupDescriptionsGets the description of grouping, indexed by level.
GroupsGets the top-level groups, constructed according to the descriptions given in GroupDescriptions.
IsAddingNewGets a value indicating whether an "AddNew" transaction is in progress.
IsCurrentAfterLastGets a value indicating whether currency is beyond the end (End-Of-File).
IsCurrentBeforeFirstGets a value indicating whether currency is before the beginning (Beginning-Of-File).
IsEditingItemGets a value indicating whether an EditItem transaction is in progress.
IsEmptyGets a value indicating whether the resulting (filtered) view is empty.
IsPageChangingGets a value indicating whether a page index change is in process or not.
Item(Int32)Return the item at the specified index
ItemCountGets the minimum number of items known to be in the source collection that verify the current filter if any
NeedsRefreshGets a value indicating whether this view needs to be refreshed.
PageIndexGets the current page we are on. (zero based)
PageSizeGets or sets the number of items to display on a page. If the PageSize = 0, then we are not paging, and will display all items in the collection. Otherwise, we will have separate pages for the items to display.
SortDescriptionsGets the Sort criteria to sort items in collection.
SourceCollectionGets the source of the IEnumerable collection we are using for our view.
TotalItemCountGets the total number of items in the view before paging is applied.

Methods

AddNew()Add a new item to the underlying collection. Returns the new item. After calling AddNew and changing the new item as desired, either CommitNew or CancelNew" should be called to complete the transaction.
CancelEdit()Complete the transaction started by . The pending changes (if any) to the item are discarded.
CancelNew()Complete the transaction started by AddNew. The new item is removed from the collection.
CommitEdit()Complete the transaction started by . The pending changes (if any) to the item are committed.
CommitNew()Complete the transaction started by AddNew. We follow the WPF convention in that the view's sort, filter, and paging specifications (if any) are applied to the new item.
Contains(Object)Return true if the item belongs to this view. No assumptions are made about the item. This method will behave similarly to IList.Contains(). If the caller knows that the item belongs to the underlying collection, it is more efficient to call PassesFilter.
DeferRefresh()Enter a Defer Cycle. Defer cycles are used to coalesce changes to the ICollectionView.
EditItem(Object)Begins an editing transaction on the given item. The transaction is completed by calling either CommitEdit or CancelEdit. Any changes made to the item during the transaction are considered "pending", provided that the view supports the notion of "pending changes" for the given item.
Equals(Object)Determines whether the specified object is equal to the current object.
(Inherited from Object)
GetEnumerator()Implementation of IEnumerable.GetEnumerator(). This provides a way to enumerate the members of the collection without changing the currency.
GetHashCode()Serves as the default hash function.
(Inherited from Object)
GetItemAt(Int32)Retrieve item at the given zero-based index in this DataGridCollectionView, after the source collection is filtered, sorted, and paged.
GetType()Gets the Type of the current instance.
(Inherited from Object)
IndexOf(Object)Return the index where the given item appears, or -1 if doesn't appear.
MoveCurrentTo(Object)Move to the given item.
MoveCurrentToFirst()Move to the first item.
MoveCurrentToLast()Move to the last item.
MoveCurrentToNext()Move to the next item.
MoveCurrentToPosition(Int32)Move CurrentItem to this index
MoveCurrentToPrevious()Move to the previous item.
MoveToFirstPage()Moves to the first page.
MoveToLastPage()Moves to the last page. The move is only attempted when TotalItemCount is known.
MoveToNextPage()Moves to the page after the current page we are on.
MoveToPage(Int32)Requests a page move to page pageIndex.
MoveToPreviousPage()Moves to the page before the current page we are on.
PassesFilter(Object)Return true if the item belongs to this view. The item is assumed to belong to the underlying DataCollection; this method merely takes filters into account. It is commonly used during collection-changed notifications to determine if the added/removed item requires processing. Returns true if no filter is set on collection view.
Refresh()Re-create the view, using any SortDescriptions and/or Filters.
Remove(Object)Remove the given item from the underlying collection. It needs to be in the current filtered, sorted, and paged view to call
RemoveAt(Int32)Remove the item at the given index from the underlying collection. The index is interpreted with respect to the view (filtered, sorted, and paged list).
ToString()Returns a string that represents the current object.
(Inherited from Object)

Events

CollectionChangedRaise this event when the (filtered) view changes
CurrentChangedRaised when the CurrentItem property changed
CurrentChangingRaised when the CurrentItem property is changing
PageChangedRaised when a page index change completed
PageChangingRaised when a page index change is requested
PropertyChangedPropertyChanged event.

Extension Methods

GetWeakCollectionChangedObservable()Gets a weak observable for the CollectionChanged event.
(Defined by NotifyCollectionChangedExtensions)
WeakSubscribe(Action(NotifyCollectionChangedEventArgs))Subscribes to the CollectionChanged event using a weak subscription.
(Defined by NotifyCollectionChangedExtensions)
WeakSubscribe(NotifyCollectionChangedEventHandler)Subscribes to the CollectionChanged event using a weak subscription.
(Defined by NotifyCollectionChangedExtensions)

See Also

Reference

Avalonia.Collections Namespace