public ContactsViewModel(IContactsService contactsService, IRegionManager regionManager)
        {
            this.emailContactCommand = new DelegateCommand <object>(this.EmailContact, this.CanEmailContact);

            this.contactsCollection           = new ObservableCollection <Contact>();
            this.contactsView                 = new PagedCollectionView(this.contactsCollection);
            this.contactsView.CurrentChanged += (s, e) => this.emailContactCommand.RaiseCanExecuteChanged();

            this.regionManager = regionManager;

            contactsService.BeginGetContacts((ar) =>
            {
                IEnumerable <Contact> newContacts = contactsService.EndGetContacts(ar);

                this.synchronizationContext.Post((state) =>
                {
                    foreach (var newContact in newContacts)
                    {
                        this.contactsCollection.Add(newContact);
                    }
                }, null);
            }, null);
        }
예제 #2
0
        public ContactsViewModel(IContactsService contactsService, IRegionManager regionManager)
        {
            this.emailContactCommand = new DelegateCommand<object>(this.EmailContact, this.CanEmailContact);

            this.contactsCollection = new ObservableCollection<Contact>();
            this.contactsView = new PagedCollectionView(this.contactsCollection);
            this.contactsView.CurrentChanged += (s, e) => this.emailContactCommand.RaiseCanExecuteChanged();

            this.regionManager = regionManager;

            contactsService.BeginGetContacts((ar) =>
            {
                IEnumerable<Contact> newContacts = contactsService.EndGetContacts(ar);

                this.synchronizationContext.Post((state) =>
                {
                    foreach (var newContact in newContacts)
                    {
                        this.contactsCollection.Add(newContact);
                    }
                }, null);

            }, null);
        }