Share via


ObservableCollectionListSource<T> Class

Definition

Extends ObservableCollection<T> and adds an explicit implementation of IListSource.

public class ObservableCollectionListSource<T> : System.Collections.ObjectModel.ObservableCollection<T>, System.ComponentModel.IListSource where T : class
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindingList raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")]
public class ObservableCollectionListSource<T> : System.Collections.ObjectModel.ObservableCollection<T>, System.ComponentModel.IListSource where T : class
type ObservableCollectionListSource<'T (requires 'T : null)> = class
    inherit ObservableCollection<'T (requires 'T : null)>
    interface IListSource
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindingList raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")>]
type ObservableCollectionListSource<'T (requires 'T : null)> = class
    inherit ObservableCollection<'T (requires 'T : null)>
    interface IListSource
Public Class ObservableCollectionListSource(Of T)
Inherits ObservableCollection(Of T)
Implements IListSource

Type Parameters

T

The type of elements in the collection.

Inheritance
ObservableCollectionListSource<T>
Attributes
Implements

Remarks

The method GetList() is implemented to return an IBindingList implementation that stays in sync with the ObservableCollection.

This class can be used to implement navigation properties on entities for use in Windows Forms data binding. For WPF data binding use an ObservableCollection rather than an instance of this class.

See Local views of tracked entities in EF Core for more information and examples.

Constructors

ObservableCollectionListSource<T>()

Initializes a new instance of the ObservableCollectionListSource<T> class.

ObservableCollectionListSource<T>(IEnumerable<T>)

Initializes a new instance of the ObservableCollectionListSource<T> class that contains elements copied from the specified collection.

ObservableCollectionListSource<T>(List<T>)

Initializes a new instance of the ObservableCollectionListSource<T> class that contains elements copied from the specified list.

Explicit Interface Implementations

IListSource.ContainsListCollection

Always false because there is never a contained collection.

IListSource.GetList()

Returns an IBindingList implementation that stays in sync with this ObservableCollection<T>. The returned list is cached on this object such that the same list is returned each time this method is called.

Extension Methods

ToBindingList<T>(ObservableCollection<T>)

Returns a BindingList<T> implementation that stays in sync with the given ObservableCollection<T>.

Applies to