public void OnAppearing(bool loadValues) { // load custom field controls var viewModel = (HouseholdEditContentViewModel)BindingContext; CustomFieldContent.Children.Clear(); foreach (var customFieldControl in viewModel.CustomFieldControls) { CustomFieldContent.Children.Add(customFieldControl); } if (!loadValues) { return; } // query values (optional) var values = new List <Tuple <CustomField, string> >(); var query = viewModel.ApplicationInstanceData.Data.CustomHouseholdValues.Where(a => a.Household.InternalId == viewModel.Household.InternalId); foreach (var result in query) { values.Add(new Tuple <CustomField, string>(result.CustomField, result.Value)); } CustomFieldInit.LoadCustomFieldValues(viewModel.CustomFields, viewModel.CustomFieldControls, values); }
public void OnAppearing(bool loadValues) { var viewModel = (PersonFollowUpEditContentViewModel)BindingContext; // Work Activities DynamicWorkActivities.Children.Clear(); var workActivitiesGrid = new Grid(); var i = 0; foreach (var bindableWorkActivity in viewModel.BindableWorkActivities) { var newWorkActivitiesGridRow = new RowDefinition(); newWorkActivitiesGridRow.Height = 80; var newWorkActivityContent = new CustomControls.GenericSwitchTextView { BindingContext = bindableWorkActivity.Item3 }; newWorkActivityContent.SetValue(Grid.RowProperty, i); workActivitiesGrid.Children.Add(newWorkActivityContent); i++; } DynamicWorkActivities.Children.Add(workActivitiesGrid); // Hazardous Conditions DynamicHazardousConditions.Children.Clear(); var hazardousConditionsGrid = new Grid(); i = 0; foreach (var bindableHazardousCondition in viewModel.BindableHazardousConditions) { var newHazardousConditionsGridRow = new RowDefinition(); newHazardousConditionsGridRow.Height = 80; var newHazardousConditionContent = new CustomControls.GenericSwitchTextView { BindingContext = bindableHazardousCondition.Item3 }; newHazardousConditionContent.SetValue(Grid.RowProperty, i); hazardousConditionsGrid.Children.Add(newHazardousConditionContent); i++; } DynamicHazardousConditions.Children.Add(hazardousConditionsGrid); // Household Tasks DynamicHouseholdTasks.Children.Clear(); var householdTasksGrid = new Grid(); i = 0; foreach (var bindableHouseholdTask in viewModel.BindableHouseholdTasks) { var newHouseholdTasksGridRow = new RowDefinition(); newHouseholdTasksGridRow.Height = 80; var newHouseholdTaskContent = new CustomControls.GenericSwitchTextView { BindingContext = bindableHouseholdTask.Item3 }; newHouseholdTaskContent.SetValue(Grid.RowProperty, i); householdTasksGrid.Children.Add(newHouseholdTaskContent); i++; } DynamicHouseholdTasks.Children.Add(householdTasksGrid); // Custom Fields CustomFieldContent.Children.Clear(); foreach (var customFieldControl in viewModel.CustomFieldControls) { CustomFieldContent.Children.Add(customFieldControl); } if (!loadValues) { return; } // query values (optional) var values = new List <Tuple <CustomField, string> >(); var query = viewModel.ApplicationInstanceData.Data.CustomPersonFollowUpValues.Where(a => a.PersonFollowUp.InternalId == viewModel.PersonFollowUp.InternalId); foreach (var result in query) { values.Add(new Tuple <CustomField, string>(result.CustomField, result.Value)); } CustomFieldInit.LoadCustomFieldValues(viewModel.CustomFields, viewModel.CustomFieldControls, values); }