Questions tagged [inotifycollectionchanged]

is a .NET interface for providing collection subscribers notification on changes, mostly used in WPF UI binding.

From MSDN: You can enumerate over any collection that implements the IEnumerable interface. However, to set up dynamic bindings so that insertions or deletions in the collection update the UI automatically, the collection must implement the INotifyCollectionChanged interface. This interface exposes the CollectionChanged event that must be raised whenever the underlying collection changes.

WPF provides the ObservableCollection class, which is a built-in implementation of a data collection that exposes the INotifyCollectionChanged interface. For an example, see How to: Create and Bind to an ObservableCollection.

The individual data objects within the collection must satisfy the requirements described in the Binding Sources Overview.

120 questions
172
votes
12 answers

ObservableCollection Doesn't support AddRange method, so I get notified for each item added, besides what about INotifyCollectionChanging?

I want to be able to add a range and get updated for the entire bulk. I also want to be able to cancel the action before it's done (i.e. collection changing besides the 'changed'). Related Q Which .Net collection for adding multiple objects at once…
26
votes
2 answers

How can I raise a CollectionChanged event on an ObservableCollection, and pass it the changed items?

I have a class that inherits from ObservableCollection and adds a few additional methods such as AddRange and RemoveRange My base method call is this: public void AddRange(IEnumerable collection) { foreach (var i in collection)…
Rachel
  • 122,023
  • 59
  • 287
  • 465
19
votes
4 answers

Observable Stack and Queue

I'm looking for an INotifyCollectionChanged implementation of Stack and Queue. I could roll my own but I don't want to reinvent the wheel.
Goran
  • 6,682
  • 9
  • 39
  • 57
16
votes
3 answers

what is notifycollectionchangedaction reset value

I have an observable collection...SelectableDataContext..And in the generic class SelectableDataContext is...having two private member variables Private T item. Private bool isSelected. When the IsSelected property changes...My…
Relativity
  • 6,210
  • 20
  • 74
  • 121
14
votes
1 answer

ObservableCollection element-wise Transform/Projection Wrapper

When creating ViewModels in WPF it's sometimes necessary to transform data that is available in an ObservableCollection (the source collection) into a collection of wrapper elements that extend/restrict/project the original elements (the target…
Peter
  • 5,193
  • 1
  • 21
  • 41
13
votes
4 answers

CollectionChanged and IList of Items - why the difficulties

I am looking into the topic why a ObservableCollection/ListCollectionView/CollectionView raises a NotSuportedException when calling the CollectionChanged with the parameter of IList. //Throws an exception private void collectionChanged_Removed(IList…
10
votes
1 answer

Observable Collection Notify when property changed in MVVM

I am trying to bind observable collection to DataGrid, i want to notify when any row is edited in datagrid. My code works fine for notifing when record is added or removed but its not notifing when record is edited. Please let me know if this is…
9
votes
3 answers

Can I rollback collection changes on collection changed event?

I have 2 list views...and add/remove buttons between them. On collection changed event of a list-view-collection in viewmodel, can i rollback the changes for a particular condition ?
Relativity
  • 6,210
  • 20
  • 74
  • 121
9
votes
4 answers

How to create a custom observable collection using ConcurrentDictionary, INotifyCollectionChanged, INotifyPropertyChanged

I am trying to create an ObservableConcurrentDictionary. This object will be used in a multithreaded application, and it's data is used to populate a control via the controls ItemsSource property. This is the implementation i have come up…
8
votes
3 answers

Why is there no ObservableKeyedCollection in the .NET Framework?

The .NET Framework contains since version 3.0 the ObservableCollection, but why isn´t there a ObservableKeyedCollection. Okay i could implement my own collection by deriving from KeyedCollection and implementing the…
Jehof
  • 32,386
  • 9
  • 115
  • 149
7
votes
3 answers

WPF: How do I hook into a ListView's ItemsSource CollectionChanged notification?

I have a ListView that is databound to an ObservableCollection ... I can't seem to find any event that are triggered when the collection changes, so I'm thinking that somehow I need to hook…
7
votes
3 answers

How does ObservableCollection.Add work?

I was trying to implement a specialized collection that works like ObservableCollection to encapsulate some more mechanisms in it, to do that i also let my collection inherit from Collection and i also implement the same interfaces. I just do not…
H.B.
  • 136,471
  • 27
  • 285
  • 357
7
votes
2 answers

Replicating changes in a list

Imagine I have a list of items: - A - B - C Now from somewhere a server tells my application that element B was removed, yet it only provides the entire new list, not the exact change details. Since WinRT ListViews automatically animate…
6
votes
1 answer

How can an ObservableCollection fire a Replace action?

In the documentation of the event args of NotifyCollectionChangedEventArgs, there is an action called Replace (in addition to Add, Remove, Move, etc.). When can this be fired? I can't see any Replace method in ObservableCollection
Louis Rhys
  • 30,777
  • 53
  • 137
  • 211
5
votes
3 answers

EntityFramework EntityCollection Observing CollectionChanged

I'm using EntityFramework database first in an application. I would like somehow to be notified of changes to an EntityCollection in my ViewModel. It doesn't directly support INotifyCollectionChanged (why?) and I haven't been successful in finding…
1
2 3 4 5 6 7 8