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
5
votes
1 answer

Getting thread access exceptions on OnCollectionChanged after Creators Update

In my program, I have an abstract class ObservableKeyedCollection that inherits from KeyedCollection and also implements INotifyCollectionChanged. A realisation of this abstract class is bound to a ListBox. In this ListBox,…
tethered.sun
  • 87
  • 3
  • 14
5
votes
1 answer

NotifyCollectionChangedEventArgs Item Inaccessible

I have a handler for the CollectionChanged event of an ObservableCollection object, and cannot figure out how to use the NotifyCollectionChangedEventArgs to retrieve the item contained within the IList for the event. New items added to the…
NWoodsman
  • 163
  • 1
  • 9
5
votes
1 answer

What is the point of INotifyCollectionChanged in terms of databinding (C# WinRt)

Background: I was trying to roll my own observable collection, by implementing IEnumerable, INotifyPropertyChanged and INotifyCollectionChanged. It works fine, but when I databind the CollectionChanged event is always null. The databound property…
5
votes
4 answers

How do I update an IValueConverter on CollectionChanged?

Here's a basic example to explain my problem. Let's say I have ObservableCollection Numbers {get; set;} and an IValueConverter that returns the sum of Numbers. Normally what I'd do is changed the IValueConverter into an IMultiValueConverter…
Bryan Anderson
  • 15,383
  • 7
  • 66
  • 81
5
votes
2 answers

INotifyCollectionChanged's NewItems - cannot use OfType to get data

I am attempting to get some custom objects from the CollectionChanged event of a collection which implements INotifyCollectionChanged. MyControl_MyCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if(e.Action ==…
dav_i
  • 25,285
  • 17
  • 94
  • 128
4
votes
6 answers

Observable LinkedList

In my WPF app, I have an ItemsControl whose items values are dependant upon the previous item displayed. The ViewModel is an audio file split into parts of variable length, and i need to display it in such manner, with a DateTime displayed on the…
Louis Kottmann
  • 15,133
  • 4
  • 56
  • 85
4
votes
3 answers

INotifyPropertyChanged or INotifyCollectionChanged with DataTable?

Hi i am having some troube with DataTables. So What i need is to detect whenever i change any cell in the DataGrid of the DataTable that is binded. How to do it? With INotifyPropertyChanged or with INotifyCollectionChanged? Note: I am trying with…
Miguel
  • 857
  • 4
  • 25
  • 46
4
votes
1 answer

Implementing INotifyCollectionChanged interface

I need to implement a collection with special capabilities. In addition, I want to bind this collection to a ListView, Therefore I ended up with the next code (I omitted some methods to make it shorter here in the forum): public class…
4
votes
2 answers

Is there a way to trigger some kind of `OnPropertyChanged` event for a computed property that uses a property of a "child entity" in a collection?

Is there a way to trigger some kind of OnPropertyChanged event for a computed property that uses a property of a "child entity" in a collection? A small example: I have a simple WPF application with a DataGrid showing Customer properties. I am…
ivanv
  • 55
  • 7
4
votes
2 answers

WPF ListBox not binding to INotifyCollectionChanged or INotifyPropertyChanged Events

I have the following test code: private class SomeItem { public string Title{ get{ return "something"; } } public bool Completed { get { return false; } set { } } } private class SomeCollection : IEnumerable,…
3
votes
2 answers

How to refresh a data-bound collection in c#?

Im writing a simple wpf application, but Im stuck. I'd like to achieve, that I have a filter class, and If the id has been changed in the filter class by a user input, a list should refresh applying the filter. All the initial bindings are working.…
3
votes
1 answer

ItemsSource + Converter + Treeview wont update

This one is fairly complex, hopefully I can make this clear enough for somebody to help me out. I have an object lets call it a Manager, the Manager has a collection of people that he manages, the people all implement IPerson, but different types of…
Kelly
  • 3,252
  • 1
  • 22
  • 24
3
votes
1 answer

Is it necessary to check NotifyCollectionChangedAction in a CollectionChanged event?

I wonder if it is necessary to check the NotifyCollectionChangedAction enum of the NotifyCollectionChangedEventArgs, when subscribing to the CollectionChanged event. Every example I stumbled upon does it like this: myCollection.CollectionChanged +=…
3
votes
2 answers

How to identify which properties of an object changed in a List

I've a Class say One with following properties class One { public int Id {get; set;} public string Name {get; set;} public string Salary {get; set;} public string Designation {get; set;} } Now I created a list of type One…
Sid M
  • 4,268
  • 4
  • 27
  • 47
3
votes
1 answer

canceling remove action - NotifyCollectionChangedAction

I am using the following code in my viewmodel to delete items out of a collection: UnitMeasureCollection.CollectionChanged += new NotifyCollectionChangedEventHandler(ListOfUnitMeasureCollectionChanged); void…
steveareeno
  • 1,795
  • 5
  • 37
  • 51