Exemplo n.º 1
0
    protected async override void OnCreate(Bundle bundle)
    {
      base.OnCreate(bundle);

      SetContentView(Resource.Layout.view_expense);

      dialog = ServiceContainer.Resolve<IMessageDialog>();

      var id = Intent.GetIntExtra("ID", -1);
      viewModel = ServiceContainer.Resolve<ExpenseViewModel>();
      await viewModel.Init(id);

      this.ActionBar.Title = viewModel.Title;
      viewModel.IsBusyChanged = (busy) =>
      {
        if (busy)
          AndHUD.Shared.Show(this, "Loading...");
        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;
    }
    public ExpenseViewController(Expense expense) : base(UITableViewStyle.Plain, null, true)
    {
      this.expense = expense;
      dialog = ServiceContainer.Resolve<IMessageDialog>();
      viewModel = ServiceContainer.Resolve<ExpenseViewModel>();
      viewModel.Init(this.expense);

      viewModel.IsBusyChanged = (busy) =>
      {
        if (busy)
          BTProgressHUD.Show("Saving...");
        else
          BTProgressHUD.Dismiss();
      };
    }
Exemplo n.º 3
0
    // When page is navigated to set data context to selected item in list
    protected async override void OnNavigatedTo(NavigationEventArgs e)
    {
      if (DataContext == null)
      {
        string selectedIndex;
        var id = -1;
        viewModel = ServiceContainer.Resolve<ExpenseViewModel>();
        if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
        {
          id = int.Parse(selectedIndex);
          
        }
       
        await viewModel.Init(id);
        DataContext = viewModel;

        TextBlockExpense.Text = viewModel.Title.ToLower();
      }


    }