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
1
vote
2 answers

How to raise NotifyCollectionChangedEventArgs with XUnit

I have a class implementing INotifyCollectionChanged and I would like to test if the CollectionChanged event is raised for specific scenarios. I've tried the code bellow but I am getting compiler errors and so far I couldn't find a solution. [Fact] …
Themelis
  • 4,048
  • 2
  • 21
  • 45
1
vote
0 answers

How can a custom iterator notify subscribers of changes to its iterated items (think 'INotifyCollectionChanged')?

We're trying to expose the contents of two child collections as an additional, all-inclusive IEnumerable property. People have suggested using CompositeCollection for this case, but there are two issues: There doesn't appear to be a read-only…
1
vote
0 answers

INotifyPropertyChanged and InotfyCollectionChanged implementation

I am building a Windows desktop application using WPF and C#. I am trying to use the MVVM model but am not able to get my head around with the model and the INotifyPropertyChanged and INotifyCollectionChanged interfaces. I am detailing below…
1
vote
1 answer

WPF Notify MultiConverter that the bound collection has changed

I am new in wpf and I am having quite a hard time trying to figure out how to notify a multiconverter that its binded collections have changed. I have tried several solutions but nothing works. I have a calendar with a multiconverter allowing me to…
1
vote
2 answers

Examples of collection changed events on Observable Collection

I have listbox in a WPF application that displays an observable collection of photo objects. When a photo is added to the collection the UI needs show the new image right away. I understand this can be handled using the CollectionChanged event. I…
MBU
  • 4,998
  • 12
  • 59
  • 98
1
vote
1 answer

Custom Observable not updating UWP ListView

I've implemented my own ObservableDictionary since A) I wasn't happy with the code I saw other people posting and B) wanted the practice. As far as I can tell, everything works correctly including notifying the listeners, but for some reason, the…
1
vote
1 answer

How to get property name from the sender object of an INotifyPropertyChanged PropertyChanged event

I have a base DependencyObject class where I have a method that takes an object, gets the properties, and for each property that is a type that implements INotifyPropertyChanged, I add a new PropertyChangedEventHandler. Now in the handler method, it…
1
vote
1 answer

Remove item in listview on Tap

This is my code: public partial class MyGS: ContentPage { public MyGS() { InitializeComponent(); BindingContext = new MyGSViewModel(); } public class MyGSViewModel: INotifyCollectionChanged { public event…
1
vote
1 answer

Passing NotifyCollectionChangedAction.Replace to NotifyCollectionChangedEventArgs fails

On custom property setter I try to call my custom event and pass NotifyCollectionChangedAction.Replace as parameter for the NotifyCollectionChangedEventArgs but I get an System.ArgumentException. What i'm doing wrong? my custom event : public event…
user6625158
1
vote
1 answer

System.InvalidOperationException 'n' index in collection change event is not valid for collection of size '0'

I'm getting this exception when triggering a CollectionChanged event on a custom implementation of INotifyCollectionChanged: An exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll but was not handled in user…
Starnuto di topo
  • 3,215
  • 5
  • 32
  • 66
1
vote
0 answers

AddRange ObservableCollection Issue

Hi I'm using this link to implement Fastest Observable Collection Best performance for ObservableCollection.AddRange ObservableCollection Doesn't support AddRange method, so I get notified for each item added, besides what about…
1
vote
0 answers

UITableView to ObservableCollection binding breaks when the containing UIViewController is initialised for the second time

I'm using mvvmcross and xamarin to bind an ObservableCollection to a UITableView. The collection is updated in place using the Add, Remove and Move methods. These calls correctly trigger INotifyCollectionChanged events and the TableView is updated…
1
vote
1 answer

Which class fired CollectionChanged event?

I have an ObservableCollection which is manipulated by a couple of classes. I want to find out which class fired the event. I already looked at the sender object and went through the properties of the NotifyCollectionChangedEventArgs but did not…
1
vote
0 answers

NotifyCollectionChanged MultiBinding does not trigger when styling a DataGrid

I am trying to use a purely style-istic approach to getting the sort ordering index in the header of my datagrid. This is the (stripped off) template:
vorrr
  • 11
  • 1
1
vote
3 answers

(Truly)ObservableCollection not updating the UI

I have a list of objects of type Emblem that I show in a LongListMultiSelector. I only want to show the ones that are not achieved yet. I can select one or more items and change them to IsAchieved = true but the problem is that they don't disappear…
1 2 3
8 9