BindableCollection<T>.AddRange implementation error

Topics: Bugs
Jan 10, 2013 at 10:39 AM

INPC.cs line 463, as of commit b70a5350a693

The implemented change in this commit causes a NotSupportedException «range actions are not supported», when executing OnCollectionChanged on line 477. The same problem occurs with RemoveRange (line 488) when executing OnCollectionChanged on line 503.

Jan 10, 2013 at 12:12 PM

On what platform (WP8, WPF or WinRT) do you have this issue?

Jan 10, 2013 at 12:14 PM
tibel wrote:

On what platform (WP8, WPF or WinRT) do you have this issue?


Jan 10, 2013 at 12:27 PM
Edited Jan 10, 2013 at 12:28 PM


var col = new BindableCollection<int>();
col.AddRange(new int[] {1,2,3});


This is working for me on .NET 4.0 and .NET 4.5
So maybe you throw this exception in your event handler attached to "CollectionChanged" event?

Jan 10, 2013 at 12:41 PM

My code is almost alike, but sends in an IList<T> as parameter (UnitCollection is a BindableCollection<Unit>):

var list = Units.Where(t => t.Primary).ToList();


The UnitCollection is set as ItemSource for a ListView in the GUI (xaml). The NotSupportedException is thrown by the System.Windows.Data.ListCollectionView when method «ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)» calls «this.ValidateCollectionChangedEventArgs(args)»

protected override void ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
	if (args == null)
		throw new ArgumentNullException("args");


private void ValidateCollectionChangedEventArgs(NotifyCollectionChangedEventArgs e)
	switch (e.Action)
	case NotifyCollectionChangedAction.Add:
		if (e.NewItems.Count != 1)
			throw new NotSupportedException(SR.Get("RangeActionsNotSupported"));

Jan 10, 2013 at 12:44 PM

Already found this article, describing the issue.
Thanks for finding the issue I will fix that.

Jan 10, 2013 at 12:51 PM

Thanks in advance!