public ChatViewModel(IChatService chatService) { this.contacts = new ObservableCollection <Contact>(); this.contactsView = new PagedCollectionView(this.contacts); this.sendMessageRequest = new InteractionRequest <SendMessageViewModel>(); this.showReceivedMessageRequest = new InteractionRequest <ReceivedMessage>(); this.showDetailsCommand = new ShowDetailsCommandImplementation(this); this.contactsView.CurrentChanged += this.OnCurrentContactChanged; this.chatService = chatService; this.chatService.Connected = true; this.chatService.ConnectionStatusChanged += (s, e) => this.RaisePropertyChanged(() => this.ConnectionStatus); this.chatService.MessageReceived += this.OnMessageReceived; this.chatService.GetContacts( result => { if (result.Error == null) { foreach (var item in result.Result) { this.contacts.Add(item); } } }); }
public ChatViewModel(IChatService chatService) { this.contacts = new ObservableCollection<Contact>(); this.contactsView = new PagedCollectionView(this.contacts); this.sendMessageRequest = new InteractionRequest<SendMessageViewModel>(); this.showReceivedMessageRequest = new InteractionRequest<ReceivedMessage>(); this.showDetailsCommand = new ShowDetailsCommandImplementation(this); this.contactsView.CurrentChanged += this.OnCurrentContactChanged; this.chatService = chatService; this.chatService.Connected = true; this.chatService.ConnectionStatusChanged += (s, e) => this.RaisePropertyChanged(() => this.ConnectionStatus); this.chatService.MessageReceived += this.OnMessageReceived; this.chatService.GetContacts( result => { if (result.Error == null) { foreach (var item in result.Result) { this.contacts.Add(item); } } }); }