gyurisc
gyurisc

Reputation: 11502

Is System.Collections.Specialized available in a PCL profile for Xamarin.Android?

I am trying to use some classes such as NotifyCollectionChangedEventArgs and NotifyCollectionChangedAction in a Portable Class Library built for a Xamarin.Android app. These are part of the System.Collections.Specialized namespace.

Whenever I am trying to compile this PCL library, the compiler reports the above mentioned namespace as missing. I could not find a PCL profile that would make this error go away.

I would like to know if it is possible to use this namespace in a PCL profile or what are the options for using it on the Xamarin.Android and Xamarin.iOS platform?

Upvotes: 0

Views: 184

Answers (1)

Cheesebaron
Cheesebaron

Reputation: 24470

The answer is yes. However, it most likely depends on the PCL profile you are choosing. So these might not be available if you are targeting Silverlight for instance.

However, creating a new PCL profile 78 works fine and these namespaces are resolvable and events trigger just fine when adding object to an ObservableCollection.

EDIT:

Profile 78 consists of: .NET 4.5 or later, Windows 8 or later, WinPhone 8 or later, Winphone Silverlight 8, Store Apps (Windows 8) and Xamarin

In order to eliminate Silverlight, although, this profile supports the two namespaces you need for NotifyPropertyChanged and CollectionChanged. Go to the project properties (Right Click > Properties). In the Library tab, just press Change and unselect anything Silverlight related. It should switch you to a profile without Silverlight. This will result in Profile 7 instead.

Now, Microsoft and NuGet team are currently making a switch to something different from these profiles called Netstandard, which hopefully will make it easier to do this in the future.

Upvotes: 2

Related Questions