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

Databinding against an INotifyCollectionChanged type

I want to have a domain model collection class and a view model class which just reflects and projects the elements of the domain model - but is itself read-only. My thought here is that both types implement the INotifyCollectionChanged interface…
Bent Rasmussen
  • 5,538
  • 9
  • 44
  • 63
2
votes
1 answer

wpf attached property with collection doesnt get updated

I like to share a list between an application and a custom Usercontrol. I use an IEnumerable as attached property to provide a list to a Listbox inside the custom UserControl. The ListBox then receives the attached property as ItemsSource. This…
2
votes
2 answers

Can't bind a MvxBindableListView in TwoWay Mode

I'm trying to bind a MvxBindableListView in TwoWay mode, for it to update in the View when I Set it's value in the ViewModel (through a Buttons's Click command). Currently it only updates when the layout is fully loaded at start/tabchange... The…
2
votes
1 answer

Adding a lot of items to WPF Datagrid consumes lots of CPU time

I am creating application that has some simple sniffer functionality and which shows the user dumped packets. Packets are read from dump file, which is updated in real time with current traffic and then captured packets are added to Datagrid (each…
2
votes
1 answer

ObservableCollection's CollectionChanged event not firing

I have a XamDataGrid which is bound to an observable collection. As the XamDataGrid is editable, records can be added/edited/deleted. I have implemented CollectionChanged & PropertyChanged events. The CollectionChanged event contains the following…
Vikram
  • 37
  • 5
1
vote
1 answer

Observable collection - CollectionChanged Binding

During programming, I ran into the following questions: Does a observable collection implement a CollectionChanged event by itself? (Because of differentbooks refering to the fact that it does, but google shows otherwise) I have the following code,…
Bart Teunissen
  • 1,420
  • 5
  • 20
  • 43
1
vote
1 answer

What triggers UI to update when ItemsControl.ItemsSource changed?

I was just looking into the difference between BindingList and ObservableCollection following this question: Why NOT BindingList in WPF As part of this, I tested binding the ItemsSource of an ItemsControl to various types, including List,…
1
vote
1 answer

Any use in hacking Silverlight NotifyCollectionChangedEventArgs to support multiple items?

The Silverlight version of NotifyCollectionChangedEventArgs differs from the full framework version, in that it does not accept multiple (added, changed, removed) items. The constructors that take lists are in fact missing, so it appears Microsoft…
CÅdahl
  • 442
  • 3
  • 13
1
vote
2 answers

Un-subscribing from CollectionChanged event of a collection stored in an attached property

Ok, so I have an attached property (declared in a static class) which attaches an INotifyCollectionChanged property to an object. When the property is set, I want to start monitoring the collection for changes, and then perform some action on the…
Mark
  • 1,784
  • 16
  • 26
1
vote
0 answers

Added item does not appear at given index '2'

I am getting this exception when I am trying to Delete the item from Dictionary which I am inheriting from INotifyCollectionChanged. When I am deleting for first time I am able to delete the item, just after that if i am trying to delete this…
Vikram
  • 1,617
  • 5
  • 17
  • 37
1
vote
2 answers

ObservableCollections and changes to properties in C#

I'm working with an observable collection of a Job class I have defined. I have binded a method to handle the INotifyCollectionChanged event. MSDN tells me that INotifyCollectionChanged is a "listener of dynamic changes, such as when items get added…
1
vote
1 answer

How to replicate the changes from INotifyCollectionChanged on another collection

I have 2 ObservableCollection objects. Let's call them A and B. I want to replicate the changes broadcasted by A (via INotifyCollectionChanged) to B. In other words, when A changes, B must replicate the same change: When A added an item, B must…
Batesias
  • 1,914
  • 1
  • 12
  • 22
1
vote
3 answers

IEnumerable changed event

I am programming an app in WinUI 3 using C#. There are some controls that have an ItemsSource property. When I pass an IEnumerable into the ItemsSource and then change the IEnumerable, the control changes accordingly. I now want to implement the…
RD4
  • 135
  • 1
  • 12
1
vote
1 answer

Correct Way to Define a Custom Bindable Property of Type ObservableCollection in Xamarin

I need to react to the content of an ObservableCollection's property changing. I define the property like this: public static readonly BindableProperty MyCollectionProperty = BindableProperty.Create( nameof(MyContentView.MyCollection), …
Vladimir
  • 1,425
  • 16
  • 31
1
vote
1 answer

MAUI - OnPropertyChange not updating the UI

Hi guys I’m working on a MAUI app and I have a problem with the ui not updating every after calling OnPRopertyChanged, here are the details: When calling a command in the ViewModel from the imageButton in the XAML file (using binding), the command…
1 2 3
8 9