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
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
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,242
  • 2
  • 18
  • 26
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,627
  • 1
  • 14
  • 37
0
votes
1 answer

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

I have subscribed to the CollectionChanged event of an ObservableCollection named m_myCollection like this: private ObservableCollection m_myCollection; public ObservableCollection MyCollection { get =>…
Vahid
  • 5,144
  • 13
  • 70
  • 146
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
  • 293
  • 6
  • 18
0
votes
1 answer

Serializing Class for Entity Database Storage

I have an atomic class I'm using to flag days of the week as true/false values. public class DaysOfWeek { public bool Sunday { get; set; } public bool Monday { get; set; } public bool Tuesday { get; set; } public bool Wednesday {…
Brad
  • 1,684
  • 4
  • 20
  • 36
0
votes
1 answer

WPF how to detach event hooks in UserControls

I have a WPF UserControl that contains a ComboBox. I need to attach an event listener to the ComboBox.Items collection. public MyUserControl() { InitializeComponent(); ((INotifyCollectionChanged)comboBox.Items).CollectionChanged += …
Mizipzor
  • 51,151
  • 22
  • 97
  • 138
0
votes
1 answer

Where is INotifyCollectionChanged?

I'm trying to use MS' ObservableConcurrentDictionary sample, but I ran into a completely unexpected problem. INotifyCollectionChanged interface is NOT found in System.Collections.Specialized namespace. The project is WinForms, and I tried targeting…
Vindicar
  • 354
  • 2
  • 9
0
votes
2 answers

Listbox UI Update after adding Item to a list of objects

I got this list: List offlinelist = new List(); It is binded to my Listbox "boardlist". Now I want that the UI of the Listbox gets updated everytime after adding a new Boardnote. I know already that i should use…
Matthias Herrmann
  • 2,650
  • 5
  • 32
  • 66
0
votes
1 answer

C#: Subscribing to event fired from another event

I'm trying to raise PropertyChangedEventHandler from a CollectionChanged callback. It gets raised, but it doesn't reach the subscriber. Perhaps I can't just treat an EventHandler like a variable? Although I have done so without issue in the past,…
0
votes
1 answer

CollectionChanged Event is not firing on a static ObservableCollection

In one class I'm adding objects to my ObservableCollection. And in another class, I'm doing stuff with my added object and then delete it from the collection. Those two classes cannot communicate with each other, so I decided to go for static…
1 2 3
8 9