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

Implementing INotfyPropertyChanged for calculated properties

I'm a bit new to MVVM, and was wondering Let's say I have defined a ObservableCollection Diffs property. I also have the following property: public bool IsSame { get { return Diffs.Count == 0; } } I dont get how…
Tomer W
  • 3,092
  • 1
  • 22
  • 38
0
votes
3 answers

Why does INotifyCollectionChanged use IList

Reading up here, I undestand why it is not IList. But why IList at all? It makes no sense to add to it, so it should be just an IEnumerable, or if you really want an indexer (no reason why), use a ReadOnlyCollection.
TDaver
  • 7,024
  • 5
  • 44
  • 91
0
votes
2 answers

using Reactive Extensions to monitor IEnumerable

I'm connecting to an object that asyncronously loads a collection of objects into an IEnumerable. At the time I connect, the IEnumerable may have items already in it's collection, and may add items during the lifetime of the application that I need…
Random
  • 1,826
  • 3
  • 19
  • 31
0
votes
0 answers

ObservableCollection CollectionChanged not firing when subscribed

I have a ObservableCollection property called ListOfFilters where if I populate the property as I am doing below, I want to fire the CollectionChanged event but it is not working. I have tried adding to the list, removing from the list but nothing…
0
votes
2 answers

Errors Changed inside Collection Changed event does not get raised

I have an fullproperty like that in my VM: public ObservableCollection ServiceHosts { get => serviceHosts; set { if (serviceHosts == value) { return; } serviceHosts = value; OnPropertyChanged(); …
Stan1k
  • 172
  • 1
  • 15
0
votes
0 answers

How to properly implement data binding for a SortedDictionary

In a WPF application, I am using a DataGrid on my main window. The data that it displays is from a SortedDictionary , where Individual is a class containing a person’s name and other facts. Specifically, the data comes from the…
0
votes
0 answers

C# Fire CollectionChanged of nested ObservableCollection by changing another class member

I'm having a problem concerning an ObservableCollection that is nested in a class. Let's first start with the class: public class Range : ObservableObject { public VSE100_RPM_Range() { MyLimit = new ObservableCollection(); …
0
votes
2 answers

WPF: what is the right way to display a 2D array in a user-drawn control

I want to make a user-drawn control for the only purpose of displaying a Color[,] array. The control itself should draw an NxM grid of rectangles of corresponding colors. I'm trying to inherit from a FrameworkElement and to override OnRender…
Pavel Murygin
  • 2,106
  • 2
  • 17
  • 24
0
votes
1 answer

Does Dispatcher.Invoke call CheckAccess internally?

I have a custom concurrent observable collection that I'm using as an ItemsSource in a WPF desktop application. For the collection to be "oberservable" I implemented INotifyCollectionChanged. Since it is "concurrent", i.e. can be modified from…
mike
  • 1,198
  • 9
  • 27
0
votes
1 answer

Get the name of the object the event is registered on in C#

I have subscribed to CollectionChanged event of ObservableCollection m_myCollection like this: private ObservableCollection m_myCollection; public ObservableCollection MyCollection { get => m_myCollection; …
Vahid
  • 4,369
  • 10
  • 55
  • 116
0
votes
1 answer

Updating a collection member's property within another collection to show in a DataGrid

How can I make it so when I change a property of a collection member in a collection it updates in the datagrid display? In my example I have an ObservableCollection of Employees. Each employee has a List property. When I assign the Employee's Car…
chrisdrhjh
  • 125
  • 3
0
votes
1 answer
0
votes
2 answers

Xamarin Custom Control binding collectionChanged to IEnumerable ItemsSource

I have custom control that takes a list of object and present them in sort of listview. public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create(nameof(ItemsSource), typeof(IEnumerable), typeof(MyCustomControl),…
0
votes
1 answer

Inserting data to XML file notify ObservableCollection

I have a parent window which has a ListView that is bound to an ObservableCollection that gets it's data from an XML file. On the parent window, I have an add button that opens a opens a Modal Window (form2.ShowDialog(), I think this is a Modal…
0
votes
1 answer

CollectionChanged - Name of Collection

I have implemented CollectionChanged for an ObservableCollection just like here: Implementing CollectionChanged Is there a possibility in the OnCollectionChanged method to find out what the name of the changed property is? EDIT: A history should be…
Pinzi
  • 263
  • 3
  • 15