// When page is navigated to set data context to selected item in list
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (DataContext == null)
            {
                string selectedId;

                viewModel = ServiceContainer.Resolve <ExpenseViewModel>();
                NavigationContext.QueryString.TryGetValue("selectedItem", out selectedId);;


                await viewModel.Init(selectedId);

                DataContext = viewModel;

                TextBlockExpense.Text = viewModel.Title.ToLower();
            }
        }
        public ExpenseViewController(Expense expense) : base(UITableViewStyle.Plain, null, true)
        {
            this.expense = expense;
            viewModel    = ServiceContainer.Resolve <ExpenseViewModel>();
            viewModel.Init(this.expense);

            viewModel.IsBusyChanged = (busy) =>
            {
                if (busy)
                {
                    BTProgressHUD.Show("Saving...");
                }
                else
                {
                    BTProgressHUD.Dismiss();
                }
            };
        }
示例#3
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.view_expense);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            //Toolbar will now take on default actionbar characteristics
            SetSupportActionBar(toolbar);
            dialog = ServiceContainer.Resolve <IMessageDialog>();

            var id = Intent.GetStringExtra("ID");

            viewModel = ServiceContainer.Resolve <ExpenseViewModel>();
            await viewModel.Init(id);

            this.SupportActionBar.Title = viewModel.Title;
            viewModel.IsBusyChanged     = (busy) =>
            {
                if (busy)
                {
                    AndHUD.Shared.Show(this, "Saving...");
                }
                else
                {
                    AndHUD.Shared.Dismiss(this);
                }
            };

            name             = FindViewById <EditText>(Resource.Id.name);
            date             = FindViewById <DatePicker>(Resource.Id.date);
            notes            = FindViewById <EditText>(Resource.Id.notes);
            total            = FindViewById <EditText>(Resource.Id.total);
            billable         = FindViewById <CheckBox>(Resource.Id.billable);
            category         = FindViewById <Spinner>(Resource.Id.category);
            category.Adapter = new ArrayAdapter <string>(this, global::Android.Resource.Layout.SimpleSpinnerDropDownItem, viewModel.Categories);
            category.SetSelection(viewModel.Categories.IndexOf(viewModel.Category));
            name.Text        = viewModel.Name;
            date.DateTime    = viewModel.Due;
            notes.Text       = viewModel.Notes;
            total.Text       = viewModel.Total;
            billable.Checked = viewModel.Billable;
        }