private void SelectContactMethod(object parameter) { _selectedContact = parameter as CompanyContact; if (_selectedContact != null) { View.ContactsPhonesGrid.ItemsSource = _selectedContact.ContactPhones; } else { View.ContactsPhonesGrid.ItemsSource = null; } RemoveContactCommand.RaiseCanExecuteChanged(); AddContactPhoneCommand.RaiseCanExecuteChanged(); RemoveContactPhoneCommand.RaiseCanExecuteChanged(); }
// Инициализация значений private void InitValues() { AlphaFilterSubject = new Subject <string>(); _alphaFilterChar = ""; AlphaFilterSubject.Subscribe(af => _filteredContacts.View.Refresh()); SearchSubstringSubject = new Subject <string>(); _searchSubstring = ""; SearchSubstringSubject.Subscribe(ss => _filteredContacts.View.Refresh()); SelectedContactSubject = new Subject <Contact>(); _selectedContact = null; SelectedContactSubject.Subscribe(sc => RemoveContactCommand.RaiseCanExecuteChanged()); _filteredContacts = new CollectionViewSource(); _filteredContacts.Filter += new FilterEventHandler(FilterByWord); _filteredContacts.Filter += new FilterEventHandler(AlphaFilter); _nextBirthdays = new CollectionViewSource(); _nextBirthdays.SortDescriptions.Add(new SortDescription("RemainingDays", ListSortDirection.Ascending)); AddContactCommand = new RelayCommand(AddContactMethod); }