Пример #1
0
 void UserAccountsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
     {
         _userAccountViewModels.Clear();
         return;
     }
     if (e.OldItems != null)
     {
         foreach (UserAccount ua in e.OldItems)
         {
             UserAcctViewModel avm = _userAccountViewModels.FirstOrDefault(vm => vm.Account == ua);
             if (avm != null)
             {
                 _userAccountViewModels.Remove(avm);
             }
         }
     }
     if (e.NewItems != null)
     {
         foreach (UserAccount ua in e.NewItems)
         {
             UserAcctViewModel avm = new UserAcctViewModel(ua);
             _userAccountViewModels.Add(avm);
         }
     }
 }
        private void PopulateAccountList()
        {
            var allUserAccounts = _accountManager.UserAccounts;

            foreach (UserAccount ua in allUserAccounts)
            {
                UserAcctViewModel avm = new UserAcctViewModel(ua);
                _userAccountViewModels.Add(avm);
            }
        }