Click or drag to resize
EnhancedObservableCollectionT Class
Inheritance Hierarchy
SystemObject
  System.Collections.ObjectModelCollectionT
    System.Collections.ObjectModelObservableCollectionT
      DW.SharpToolsThreadedObservableCollectionT
        DW.SharpToolsEnhancedObservableCollectionT

Namespace: DW.SharpTools
Assembly: DW.SharpTools (in DW.SharpTools.dll) Version: 2.4.0.0 (2.4.0.0)
Syntax
C#
public class EnhancedObservableCollection<T> : ThreadedObservableCollection<T>

Type Parameters

T
The type of elements in the collection.

The EnhancedObservableCollectionT type exposes the following members.

Constructors
Methods
  NameDescription
Public methodAddRange
Adds the elements of the specified collection to the end of the DW.SharpTools.EnhancedObservableCollection{T}.
Protected methodClearItems
Called internally to remove all items from the collection with taking care about if CatchPropertyChanged is set to true.
(Overrides ObservableCollectionTClearItems.)
Protected methodOnCollectionChanged
Called internally to catch or remove event handlers to the PropertyChanged if CatchPropertyChanged is set to true.
(Overrides ObservableCollectionTOnCollectionChanged(NotifyCollectionChangedEventArgs).)
Public methodRemoveAll
Removes all the elements that match the conditions defined by the specified predicate.
Public methodRemoveRange
Removes a range of elements from the DW.SharpTools.EnhancedObservableCollection{T}.
Public methodSort
Sorts the elements in the entire System.Collections.Generic.List{T} using the default comparer.
Public methodSort(IComparerT)
Sorts the elements in the entire DW.SharpTools.EnhancedObservableCollection{T} using the specified comparer.
Public methodSort(ComparisonT)
Sorts the elements in the entire DW.SharpTools.EnhancedObservableCollection{T} using the specified System.Comparison{T}.
Public methodSort(Int32, Int32, IComparerT)
Sorts the elements in a range of elements in DW.SharpTools.EnhancedObservableCollection{T} using the specified comparer.
Top
Properties
  NameDescription
Public propertyCatchPropertyChanged
Gets or sets if the PropertyChanged of the inner items has to be catched and forwarded by the ItemPropertyChanged. The default is false.
Public propertySelectedItem
Gets or sets an item with the type of the items in the EnhancedObservableCollectionT.
Top
Events
  NameDescription
Public eventItemPropertyChanged
Occurs when an inner item has sent PropertyChanged.
Top
Examples
C#
public partial class MainViewModel : UserControl
{
    public MainViewModel()
    {
        Items = new EnhancedObservableCollection<char>();
    }

    public EnhancedObservableCollection<char> Items { get; private set; }

    private void AddAlphabet()
    {
        Items.AddRange(Enumerable.Range('a', 26).Select(i => (char)i));
    }

    private void Sort()
    {
        Items.Sort();
    }

    private void Revert()
    {
        Items.Sort(Revert);
    }

    private static int Revert(char lhv, char rhv)
    {
        return rhv.CompareTo(lhv);
    }
}
XAML
<DockPanel>
    <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Center">
        <Button Content="Add Alphabet" Command="{Binding AddAlphabetCommand}" />
        <Button Content="Sort" Command="{Binding SortCommand}" />
        <Button Content="Revert" Command="{Binding RevertCommand}" />
    </StackPanel>

    <ListBox ItemsSource="{Binding Items}" />
</DockPanel>
See Also