Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

New Post: BindableCollection.AddRange implementation error

$
0
0

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();

UnitCollection.Clear()
UnitCollection.AddRange(list);

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)»

protectedoverridevoid ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
{if (args == null)
	{thrownew ArgumentNullException("args");
	}this.ValidateCollectionChangedEventArgs(args);
	...

and 

privatevoid ValidateCollectionChangedEventArgs(NotifyCollectionChangedEventArgs e)
{switch (e.Action)
	{case NotifyCollectionChangedAction.Add:if (e.NewItems.Count != 1)
		{thrownew NotSupportedException(SR.Get("RangeActionsNotSupported"));
		}break;
		...


Viewing all articles
Browse latest Browse all 1760

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>