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.

129 questions
3
votes
2 answers

How to destroy or detach a CollectionView

I observe an odd behaviour of WPF ItemsControls: If a set the ItemsSource to an object which implements INotifyCollectionChanged and after that set the ItemsSource to null, the CollectionView which was created to provide the data to the ItemsControl…
HCL
  • 36,053
  • 27
  • 163
  • 213
3
votes
1 answer

How can I listen to INotifyCollectionChanged in a wpf user control

I have a user control. there I want to maintain a collection as a dependency property. Suppose that property is bound to a collection which implements INotifyCollectionChanged. Now suppose the collection got added or removed with some item how can i…
Mintu
  • 31
  • 2
3
votes
1 answer

Observable binding to two ICollectionView of same collection

So I'm using WPF in the MVVM way using Caliburn.Micro as a framework. I have a ViewModel with a ObservableCollection that I need to show twice with different sorting, filtering and grouping. I'm kind of having a hard time with this supposedly simple…
3
votes
2 answers

INotifyCollectionChanged is not updating the UI

I have a class as shown below. All the functions I have removed for brevity public class PersonCollection:IList {} Now I have one more Model class as shown below. AddValueCommand is class deriving from ICommand which again I am…
Vikram
  • 1,617
  • 5
  • 17
  • 37
3
votes
1 answer

INotifyCollectionChanged insufficient for databound control to update?

I'm trying to implement a bindable collection - a specialized stack - which needs to be displayed on one page of my Windows 8 app along with any updates made to it as they happen. For this, I've implemented INotifyCollectionChanged and…
3
votes
1 answer

In WinRT, A Collection that implements INotifyCollectionChanged not Updating ItemsControl

I am writing my own collection class that also implements INotifyCollectionChanged. I am using it in a windows 8 store application (winRT). I wrote a unit test that proves that modifying the content of the list raises all the proper events with the…
Kobi Hari
  • 1,259
  • 1
  • 10
  • 25
3
votes
1 answer

How to get the changed item in the NotifyCollectionChangedEventArgs?

I have made an ObservableCollection that fires a CollectionChangedEvent every time a Property of the objects in the collection (T: INPC) is changed. I want to know which property of T has fired the CollectionChangedEvent, so I tried the…
2
votes
0 answers

Why isn't my CollectionChanged event handler getting called?

I have done some research and other answers on stackoverflow indicate that I need to extend the ObservableCollection class to add PropertyChanged event handlers to each item when an item is added or removed in order to get events when the contents…
2
votes
1 answer

ObservableCollection and CollectionChanged event as WCF datacontract

I use DataContract with ObservableCollection: [DataContract(Namespace = Terms.MyNamespace)] public class MyContract { internal MyContract () { List = new ObservableCollection(); } [DataMember] private…
weqew q
  • 271
  • 3
  • 10
2
votes
3 answers

INotifyCollectionChanged -- How often does it fire (and how do they make it so efficient/fast)?

Basically, I'm wondering how it is actually efficient here. Sample code: void GetItems() { foreach (var item in items) myObservableCollection.Add(item); } Won't this fire off the CollectionChanged event every time causing the UI to have…
michael
  • 14,844
  • 28
  • 89
  • 177
2
votes
1 answer

How to bind ObservableCollection of mutable model to ReadOnlyObservableCollection of viewmodel using ReactiveUI and DynamicData

I'm using ReactiveUI and DynamicData in my C# project. However, domain model classes still rely on C# events, INotifyPropertyChanged and INotifyCollectionChanged interfaces. There are Model and ViewModel classes: public class Model { public…
2
votes
1 answer

What is alternative of ASP.NET DataBind() in WPF?

I'm ad ASP.NET developer but recently develop WPF applications too. In ASP.NET whenever I needed to refresh data in a GridView I just call DataBind(). But what is alternative of it in WPF? As a work-around I currently implemented…
Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126
2
votes
3 answers

Who uses NotifyCollectionChangedEventArgs' features?

This is a follow-up to my question, How does WPF handle CollectionChanged events for custom collections?. According to Alex.Wei's answer (and the source code of IndexedEnumerable) WPF ignores the specifics of the NotifyCollectionChangedEventArgs…
mike
  • 1,627
  • 1
  • 14
  • 37
2
votes
2 answers

NotifyCollectionChangedAction: object instance on removal?

I am currently implementing the INotifyCollectionChanged interface for a collection with generally quite critical and short-lived items. All of those items implement IDispose, which can be called immediatly before the removal from the collection. I…
Marcus Riemer
  • 7,244
  • 8
  • 51
  • 76
2
votes
1 answer

How to listen to CollectionChanged event and execute some method

My viewmodel has two Collections, one is MainCollection and other is DerivedCollection. They are displayed using a control, so that when user interacts with the mouse, items can be added or removed from MainCollection, and DerivedCollection should…
heltonbiker
  • 26,657
  • 28
  • 137
  • 252
1 2
3
8 9