Пример #1
0
        async void OnAddAccount(object sender, EventArgs e)
        {
            var page = new AccountDetailPage(new Account());

            page.AccountAdded += (source, account) =>
            {
                account.Status = "created";
                _connection.InsertAsync(account);
                _accounts.Add(account);
            };

            await Navigation.PushAsync(page);

            //Clear search bar text when returning to page
            searchBar.Text = null;
        }
Пример #2
0
        async void OnAccountSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (accountsListView.SelectedItem == null)
            {
                return;
            }

            var selectedAccount = e.SelectedItem as Account;

            accountsListView.SelectedItem = null;


            var page = new AccountDetailPage(selectedAccount);

            page.AccountUpdated += (source, account) =>
            {
                var updatedAccount = new Account();

                updatedAccount.Name   = account.Name;
                updatedAccount.A_Note = account.A_Note;
                updatedAccount.B_Note = account.B_Note;
                updatedAccount.C_Note = account.C_Note;
                updatedAccount.D_Note = account.D_Note;
                updatedAccount.E_Note = account.E_Note;
                updatedAccount.Status = account.Status;

                _connection.DeleteAsync(selectedAccount);
                _accounts.Remove(selectedAccount);

                _connection.InsertAsync(updatedAccount);
                _accounts.Add(updatedAccount);

                Update();
            };

            await Navigation.PushAsync(page);

            //Clear search bar text when returning to page
            searchBar.Text = null;
        }