private async void getAccounts() { setWorking(true); var acts = await _app.Client.MyAccountsAsync(); var accounts = acts.OrderBy(o => o.BoxId).ToList(); _accountViewModels = new ObservableCollection<AccountViewModel>(); accounts.ForEach((a) => { AccountViewModel avm = new AccountViewModel(); MyAccount ma = new MyAccount(a); avm.Account = ma; _accountViewModels.Add(avm); }); _accountViewModels.Add(new AccountViewModel() { Account = new MyAccount(), IsNew = true }); lv_Accounts.DataContext = _accountViewModels; setWorking(false); }
private void btn_Add_Click(object sender, RoutedEventArgs e) { beginAnimation(_isEdit); setCommonStatus(); tb_Box.IsEnabled = true; if(_isEdit) { _myAccount = new MyAccount(); _myAccount.IsAvailable = true; _myAccount.AcctUsers = new ObservableCollection<AccountUser>(); gd_Account.DataContext = _myAccount; dg_User.DataContext = _myAccount.AcctUsers; } }
private void lv_Accounts_SelectionChanged(object sender, SelectionChangedEventArgs e) { var avm = lv_Accounts.SelectedItem as AccountViewModel; if (avm != null) { _myAccount = avm.Account; btn_Edit.IsEnabled = true; } }