Frage

I want to use the Portable Class Project for my MVVM-Concept (share the dll between WPF and Silverlight).

For WPF I want to target Dot.Net 4.0 and Silverlight targets Version 5.

Sadly the portable project does not support some key features for my view-model like the ObservableCollection. Curiosly the ObservableCollection is supported in both standalone versions (Dot.Net 4.0 and SL 5).

Has anyone an idea why I can't use this collection? When I switch to Dot.Net 4.5 it is available.

War es hilfreich?

Lösung

This is just a result of the fact that .NET 4.0 was the first version of .NET that supported portable libraries, and we didn't have time to make the "ViewModel" types (ICommand, ObservableCollection, etc) portable.

The technical reason is that the types are in System.Windows.dll on Silverlight, but they were in a WPF assembly (PresentationCore.dll I think) in the .NET Framework. In .NET 4.5 we added a version of System.Windows.dll to the .NET Framework with type-forwards to the right place.

Andere Tipps

Because the type in question does not exist in the intersection of the selected framework types / versions. Not all types exist everywhere. The nature of PCL is that you can only use types that are common to all the targets.

Some types can be used between platforms by taking a dependency on Microsoft.Bcl (which adds in missing types); howver, I do not think that observable collections are included in this.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top