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
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
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
vote
0 answers

Proper pattern for C# assignment, property of object is collection

I have a class that exposes different types of collections as properties, like List
and SortedSet. I understand collection classes should be read-only, that we should not expose a collection for update, like person.Address[3].City =…
1
vote
1 answer

DataGridView and INotifyCollectionChanged

I had it in my mind that if I implemented INotifyCollectionChanged on my Custom Collection that the DataGridView would subscribe to the CollectionChanged event. My Collection implements IListSource and INotifyCollectionChanged, and has an internal…
BVernon
  • 2,386
  • 3
  • 21
  • 45
1
vote
1 answer

Add CollectionChanged to ObservableColleciton without knowing collection type

I am trying to add a CollectionChanged event to any item within a class. Assume I have the following: public class A { string OneString; string TwoString; ObservableCollection CollectionOfB; } public class B { string ThreeString; …
1
vote
1 answer

Handling ObservableCollection CollectionChanged Event

I've seen code like the following in the Silverlight toolkit and can't understand how it is safe to do: private void ItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { // Update the cache if (e.Action ==…
1
vote
1 answer

How to Bind Data to DataGrid at Run-Time

All, I have some test code that works with some test data defined as private ObservableCollection _testData = new ObservableCollection(); public ObservableCollection TestData { get { return _testData; } set…
MoonKnight
  • 23,430
  • 34
  • 134
  • 249
1
vote
1 answer

How to get the changed item in the NotifyCollectionChangedEventArgs?

I have made an ObservableCollection that fires a CollectionChangedEvent every time a Property of the objects in the collection (T: INPC) is changed. I want to know which property of T has fired the CollectionChangedEvent, so I tried the…
1
vote
1 answer

Why does DataGrid call collection's IndexOf passing the object of type ItemcControl.ItemInfo?

I created SelectionHelper for DataGrid which allows binding for selected items in both directions. In this helper I call ScrollIntoView for the first selected item, when selection changes from viewmodel. The call successfully returns. But later…
Pavel Voronin
  • 11,811
  • 6
  • 54
  • 113