ThreadedObservableCollectionT Class |
Namespace: DW.SharpTools
public class ThreadedObservableCollection<T> : ObservableCollection<T>
The ThreadedObservableCollectionT type exposes the following members.
Name | Description | |
---|---|---|
![]() | ThreadedObservableCollectionT |
Initializes a new instance of the DW.SharpTools.ThreadedObservableCollection{T} class.
|
![]() | ThreadedObservableCollectionT(IEnumerableT) |
Initializes a new instance of the DW.SharpTools.ThreadedObservableCollection{T} class that contains elements copied from the specified collection.
|
![]() | ThreadedObservableCollectionT(ListT) |
Initializes a new instance of the DW.SharpTools.ThreadedObservableCollection{T} class that contains elements copied from the specified list.
|
Name | Description | |
---|---|---|
![]() | Add |
Adds an object to the end of the DW.SharpTools.ThreadedObservableCollection{T}.
|
![]() | Clear |
Removes all elements from the DW.SharpTools.ThreadedObservableCollection{T}.
|
![]() | Insert |
Inserts an element into the DW.SharpTools.ThreadedObservableCollection{T} at the specified index.
|
![]() | Move |
Moves the item at the specified index to a new location in the DW.SharpTools.ThreadedObservableCollection{T}.
|
![]() | Remove |
Removes the first occurrence of a specific object from the DW.SharpTools.ThreadedObservableCollection{T}.
|
![]() | RemoveAt |
Removes the element at the specified index of the DW.SharpTools.ThreadedObservableCollection{T}.
|
Name | Description | |
---|---|---|
![]() | Dispatcher |
Gets or sets the dispatcher to be used for each item change in the collection. The default value is the CurrentDispatcher at the time the collection has been created.
|
![]() | DispatcherAccess |
Gets or sets the way how actions on the dispatcher has to be invoked. The default value is Invoke. This can be changes using the ThreadedObservableCollectionConfiguration.
|
![]() | DispatcherPriority |
Gets or sets the priority passed to the dispatcher invoke. The default value is Normal. This can be changes using the ThreadedObservableCollectionConfiguration.
|
![]() | Item |
Gets or sets the element at the specified index.
|
public class MainViewModel { public MainViewModel() { Items = new ThreadedObservableCollection<string>(); } public ThreadedObservableCollection<string> Items { get; private set; } private void Add() { new TaskFactory().StartNew(() => Items.Add(Guid.NewGuid().ToString())); } private void Remove() { if (!Items.Any()) return; new TaskFactory().StartNew(() => Items.Remove(Items.First())); } }
<DockPanel> <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Center"> <Button Content="Add Multithreaded" Command="{Binding AddCommand}" /> <Button Content="Remove Multithreaded" Command="{Binding RemoveCommand}" /> </StackPanel> <ListBox ItemsSource="{Binding Items}" /> </DockPanel>