Reputation: 143
As per the documentation for Portable Class Libraries, the ViewModel support in Portable Class Libraries does not exist for .NET Framework 4, but does exist in .NET Framework 4.5. Unfortunately, this makes adopting Portable Class Libraries a tricky proposition, as about half of our customers are still on XP, and therefore unable to upgrade to 4.5.
Interestingly enough the necessary classes (as described on http://msdn.microsoft.com/en-us/library/gg597391(v=vs.100).aspx#sectionToggle3 and http://msdn.microsoft.com/en-us/library/gg597391.aspx#mvvm ) do exist in .NET Framework 4. From what I gather, it should be possible to ship a System.Windows.dll that forwards the types to the appropriate .NET Framework 4 dll's, if I give up INotifyDataError (and the accompanying DataErrorsChangedEventArgs).
Would it be possible to simply take the System.Windows.dll that is shipped with .NET Framework 4.5, strip out the references to INotifyDataError and DataErrorsChangedEventArgs, redirect the references to System.dll to PresentationCore.dll where necessary and then reference that retargetable System.Windows.dll from the project destined to run on .NET Framework 4? Or will I run into difficult-to-debug shadowing issues if by chance the project is run on .NET Framework 4.5?
I was hoping this might be as doable as e.g. http://nuget.org/packages/Microsoft.Bcl
Upvotes: 3
Views: 429
Reputation: 9991
Did you notice that if you install .NET 4.0.3 runtime update on the target machine (and specifically target 4.0.3 in your PCL) then you can use your portable library with additional features on the .NET4 (i.e. 4.0.3) platform? Hope this helps.
Upvotes: 1