DataGridCollectionView Class

Summary

DataGrid-readable view over an IEnumerable.
Namespace
Avalonia.Collections
Interfaces
  • IDataGridCollectionView
  • IEnumerable
  • INotifyCollectionChanged
  • IDataGridEditableCollectionView
  • INotifyPropertyChanged
Base Types
  • object
graph BT Type-->Base0["object"] Type-.->Interface0["IDataGridCollectionView"] Type-.->Interface1["IEnumerable"] Type-.->Interface2["INotifyCollectionChanged"] Type-.->Interface3["IDataGridEditableCollectionView"] Type-.->Interface4["INotifyPropertyChanged"] Type["DataGridCollectionView"] class Type type-node

Syntax

public sealed class DataGridCollectionView : IDataGridCollectionView, IEnumerable, 
    INotifyCollectionChanged, IDataGridEditableCollectionView, INotifyPropertyChanged

Constructors

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

Events

Name Type Summary
CollectionChanged NotifyCollectionChangedEventHandler
Raise this event when the (filtered) view changes
CurrentChanged EventHandler
Raised when the CurrentItem property changed
CurrentChanging EventHandler<DataGridCurrentChangingEventArgs>
Raised when the CurrentItem property is changing
PageChanged EventHandler<EventArgs>
Raised when a page index change completed
PageChanging EventHandler<PageChangingEventArgs>
Raised when a page index change is requested
PropertyChanged PropertyChangedEventHandler
PropertyChanged event.

Properties

Name Value Summary
CanAddNew bool
Gets a value indicating whether the view supports AddNew.
CanCancelEdit bool
Gets 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.
CanChangePage bool
Gets a value indicating whether the PageIndex value is allowed to change or not.
CanFilter bool
Gets a value indicating whether we support filtering with this ICollectionView.
CanGroup bool
Gets a value indicating whether this view supports grouping. When this returns false, the rest of the interface is ignored.
CanRemove bool
Gets a value indicating whether the view supports Remove and RemoveAt.
CanSort bool
Gets a value indicating whether we support sorting with this ICollectionView.
Count int
Gets the number of records in the view after filtering, sorting, and paging.
Culture CultureInfo
Gets or sets Culture to use during sorting.
CurrentAddItem object
Gets the new item when an AddNew transaction is in progress Otherwise it returns null.
CurrentEditItem object
Gets the affected item when an EditItem transaction is in progress Otherwise it returns null.
CurrentItem object
Gets the "current item" for this view
CurrentPosition int
Gets the ordinal position of the CurrentItem within the (optionally sorted and filtered) view.
Filter Func<object, bool>
Gets 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.
GroupDescriptions AvaloniaList<DataGridGroupDescription>
Gets the description of grouping, indexed by level.
Groups IAvaloniaReadOnlyList<object>
Gets the top-level groups, constructed according to the descriptions given in GroupDescriptions.
IsAddingNew bool
Gets a value indicating whether an "AddNew" transaction is in progress.
IsCurrentAfterLast bool
Gets a value indicating whether currency is beyond the end (End-Of-File).
IsCurrentBeforeFirst bool
Gets a value indicating whether currency is before the beginning (Beginning-Of-File).
IsEditingItem bool
Gets a value indicating whether an EditItem transaction is in progress.
IsEmpty bool
Gets a value indicating whether the resulting (filtered) view is empty.
IsPageChanging bool
Gets a value indicating whether a page index change is in process or not.
ItemCount int
Gets the minimum number of items known to be in the source collection that verify the current filter if any
NeedsRefresh bool
Gets a value indicating whether this view needs to be refreshed.
PageIndex int
Gets the current page we are on. (zero based)
PageSize int
Gets 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.
SortDescriptions DataGridSortDescriptionCollection
Gets the Sort criteria to sort items in collection.
SourceCollection IEnumerable
Gets the source of the IEnumerable collection we are using for our view.
this[int] object
Return the item at the specified index
TotalItemCount int
Gets the total number of items in the view before paging is applied.

Methods

Name Value Summary
AddNew() object
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() void
Complete the transaction started by . The pending changes (if any) to the item are discarded.
CancelNew() void
Complete the transaction started by AddNew. The new item is removed from the collection.
CommitEdit() void
Complete the transaction started by . The pending changes (if any) to the item are committed.
CommitNew() void
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) bool
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() IDisposable
Enter a Defer Cycle. Defer cycles are used to coalesce changes to the ICollectionView.
EditItem(object) void
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.
GetEnumerator() IEnumerator
Implementation of IEnumerable.GetEnumerator(). This provides a way to enumerate the members of the collection without changing the currency.
GetItemAt(int) object
Retrieve item at the given zero-based index in this DataGridCollectionView, after the source collection is filtered, sorted, and paged.
IndexOf(object) int
Return the index where the given item appears, or -1 if doesn't appear.
MoveCurrentTo(object) bool
Move to the given item.
MoveCurrentToFirst() bool
Move to the first item.
MoveCurrentToLast() bool
Move to the last item.
MoveCurrentToNext() bool
Move to the next item.
MoveCurrentToPosition(int) bool
Move CurrentItem to this index
MoveCurrentToPrevious() bool
Move to the previous item.
MoveToFirstPage() bool
Moves to the first page.
MoveToLastPage() bool
Moves to the last page. The move is only attempted when TotalItemCount is known.
MoveToNextPage() bool
Moves to the page after the current page we are on.
MoveToPage(int) bool
Requests a page move to page pageIndex.
MoveToPreviousPage() bool
Moves to the page before the current page we are on.
PassesFilter(object) bool
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() void
Re-create the view, using any SortDescriptions and/or Filters.
Remove(object) void
Remove the given item from the underlying collection. It needs to be in the current filtered, sorted, and paged view to call
RemoveAt(int) void
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).