public NewReportPage() { NavigationPage.SetTitleIcon(this, "icon.png"); ViewModel = new NewReportPageViewModel(); BindingContext = ViewModel; Title = "New Report"; Content = new StackLayout { Padding = new Thickness(0, 0, 0, 10), Children = { dashboard, expenseList, saveReportButton, cancelReportButton } }; #region Set Event Handlers and Bindings saveReportButton.Clicked += HandleSaveReport; cancelReportButton.Clicked += HandleCancelReport; addExpense.Clicked += HandleAddExpense; expenseList.ItemSelected += HandleItemSelected; expenseList.SetBinding(ListView.ItemsSourceProperty, "Expenses"); reportName.SetBinding(Entry.TextProperty, "ReportName", BindingMode.TwoWay); reportTotal.SetBinding(Label.TextProperty, "ReportTotal", BindingMode.OneWay, null, "$ {0}"); status.SetBinding(Label.TextProperty, "ReportStatus"); #endregion }
public ReportDetailPage(ExpenseReport report) { NavigationPage.SetTitleIcon(this, "icon.png"); ViewModel = new ReportDetailViewModel(report); BindingContext = ViewModel; AddConditionalUI(); Content = layout; if (report.Status == "PendingApproval") { submitButton.Text = "Unsubmit Report"; } #region Set Event Handlers and Bindings if (submitButton != null) { submitButton.Clicked += HandleSubmitReport; } if (deleteButton != null) { deleteButton.Clicked += HandleDeleteReport; } if (addExpense != null) { addExpense.Clicked += HandleAddExpense; } TapGestureRecognizer tap = new TapGestureRecognizer(); editNameImage.GestureRecognizers.Add(tap); tap.Tapped += ViewModel.ToggleEdit; expenseList.ItemSelected += HandleExpenseSelected; expenseList.SetBinding <ReportDetailViewModel>(ListView.ItemsSourceProperty, vm => vm.Report.Expenses); reportName.SetBinding <ReportDetailViewModel>(Entry.TextProperty, vm => vm.Report.ReportName); reportName.SetBinding <ReportDetailViewModel>(Entry.IsEnabledProperty, vm => vm.IsEditing); reportTotal.SetBinding <ReportDetailViewModel>(Label.TextProperty, vm => vm.Report.Total.ToString("C")); status.SetBinding <ReportDetailViewModel>(Label.TextProperty, vm => vm.ReportStatus); editNameImage.SetBinding <ReportDetailViewModel>(Image.SourceProperty, vm => vm.NameEditImageSource); #endregion }