似乎是在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; ...}@H_502_4@解决方法 是的,MSDN在这一点上令人困惑(是否有错误?)
基本上,你无事可做!
在创建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)); } } }
我们试试吧 !
@H_502_4@ @H_502_4@ @H_502_4@ @H_502_4@ 总结以上是内存溢出为你收集整理的wpf – 可移植类库中的ViewModel支持全部内容,希望文章能够帮你解决wpf – 可移植类库中的ViewModel支持所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)