当前位置: 代码迷 >> Windows Mobile >> 没法使用集合初始值初始化类型,原因是它未实现“System.Collections.IEnumerable”
  详细解决方案

没法使用集合初始值初始化类型,原因是它未实现“System.Collections.IEnumerable”

热度:4151   发布时间:2013-02-26 00:00:00.0
无法使用集合初始值初始化类型,原因是它未实现“System.Collections.IEnumerable”
public class BookViewModel:INotifyPropertyChanged
    {
        
        //定义书类的集合
        private ObservableCollection<BookModel> bookModel;
        //将集合作为ViewModel层的属性
        public ObservableCollection<BookModel> Book
        {
            get
            {
                if (bookModel == null)
                {
                    bookModel = new ObservableCollection<BookModel>();
                }
                return bookModel;
            }
            set
            {
                if (bookModel != value)
                {
                    bookModel = value;
                    NotifyPropertyChanged("AllFruit");
                }
            }
        }

        //定义属性改变事件
        public event PropertyChangedEventHandler PropertyChanged;
        //实现属性改变事件
        private void NotifyPropertyChanged(string p)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(p));
            }
        }

        public void getBook()
        {
            ServiceReference1.Service1SoapClient s = new ServiceReference1.Service1SoapClient();
            s.getBooksCompleted += new EventHandler<ServiceReference1.getBooksCompletedEventArgs>(s_getBooksCompleted);
            s.getBooksAsync();
        }
  相关解决方案