ViewModel support in Portable Class Library

I am trying out the PCL in a VS 2010 project in which I would like to support WPF (4 and higher) and Silverlight (4 and higher). The MS documentation excerpt below is confusing to me.

It seems to be saying to reference System.Windows in the PCL project, but I don't see how to do that.

What must I do to have ICommand and INotifyPropertyChanged in my PCL project?

Supporting the View Model Pattern When you target Silverlight and Windows Phone 7, you can implement the view model pattern in your solution. The classes to implement this pattern are located in the System.Windows.dll assembly from Silverlight. The System.Windows.dll assembly is not supported when you create a Portable Class Library project that targets the .NET Framework 4 or Xbox 360.

The classes in this assembly include the following:

System.Collections.ObjectModel.ObservableCollection

System.Collections.ObjectModel.ReadOnlyObservableCollection

System.Collections.Specialized.INotifyCollectionChanged

System.Collections.Specialized.NotifyCollectionChangedAction

System.Collections.Specialized.NotifyCollectionChangedEventArgs

System.Collections.Specialized.NotifyCollectionChangedEventHandler

System.Windows.Input.ICommand

The .NET Framework 4 also contains these classes, but they are implemented in assemblies other than System.Windows.dll. To use these classes with a Portable Class Library project, you must reference System.Windows.dll and not the assemblies listed in the .NET Framework 4 documentation

EDIT

INotifyPropertyChanged is NOT available; the code below will not compile

    public abstract class ViewModelBase : INotifyPropertyChanged
{
    public virtual event PropertyChangedEventHandler PropertyChanged;

    ...

}

Answers


Yes, the MSDN is confusing on this point (is there an error ?)

Basically, you have nothing to do !

Whe you create your PCL project, simply select appropriate frameworks.

PCL automatically manage references for you.

 public abstract class ViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }
    }

Let's try !


Need Your Help

Python, writing things to json

python json python-3.x

I'm in this sort of a situation. I have 2 lists and two ints, I need to put them all into a JSON file so that I can pass it to another Python program. I would like the final file/structure to be

Using ActiveDirectoryMembershipProvider with two domain controllers

asp.net active-directory directoryservices

We have an ASP.NET application running at a customer site that uses ActiveDirectory for user login via the ActiveDirectoryMembershipProvider. Their primary domain controller that we were pointing t...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.