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();
}