似乎是在PCL项目中引用System.Windows,但我不知道如何做到这一点.
我必须做什么才能在我的PCL项目中使用ICommand和INotifyPropertyChanged?
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
编辑
INotifyPropertyChanged不可用;下面的代码不会编译
public abstract class viewmodelBase : INotifyPropertyChanged { public virtual event PropertyChangedEventHandler PropertyChanged; ... }
解决方法
基本上,你无事可做!
在创建PCL项目时,只需选择适当的框架即可.
PCL会自动为您管理参考.
public abstract class viewmodelBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propName) { if (PropertyChanged != null) { PropertyChanged(this,new PropertyChangedEventArgs(propName)); } } }
我们试试吧 !
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。