private void entry_unfocused(object sender, FocusEventArgs e) { try { if (string.IsNullOrEmpty(CurrentActiveResponse)) { var mainParent = (Grid)((StackLayout)((StackLayout)((Grid)((Frame)((Grid)((Entry)sender).Parent).Parent).Parent).Parent).Parent).Parent; var child0 = ((Grid)((Frame)mainParent.Children[0]).Content).Children[0] as Label; if (child0 != null) { CurrentActiveResponse = child0.Text; } var containerParent = (StackLayout)((FlexLayout)((StackLayout)(mainParent.Parent)).Parent).Parent; if (containerParent != null) { CurrentActiveQuestionId = ((Label)(containerParent.Children[0])).Text; if (string.IsNullOrEmpty(CurrentActiveQuestionId)) { CurrentActiveQuestionId = (((StackLayout)((StackLayout)(containerParent.Parent)).Parent)?.Children[0] as Label)?.Text; } } } if (SurveySummaries.Count(a => a.AnswerText.ToLower() == CurrentActiveResponse.ToLower()) == 0) { SurveySummaries.Add(new SurveySummary { AnswerText = CurrentActiveResponse, SubAnswerText = SubAnswerText, ConfigAnswerText = ((Entry)sender).Text }); } else { SurveySummaries.Where(a => a.AnswerText.ToLower() == CurrentActiveResponse.ToLower()).ForEach(x => { x.ConfigAnswerText = ((Entry)sender).Text; }); } CurrentActiveResponse = string.Empty; CurrentAnswerText = string.Empty; SubAnswerText = string.Empty; } catch (Exception) { } }
private void SubOptionClicked(object sender, EventArgs e) { try { if (((Button)sender).BackgroundColor == Color.FromHex("#000")) { ((Button)sender).BackgroundColor = Color.FromHex("#fff"); ((Button)sender).TextColor = Color.FromHex("#000"); } else { ((Button)sender).BackgroundColor = Color.FromHex("#000"); ((Button)sender).TextColor = Color.FromHex("#fff"); } var parent1 = ((Button)sender).Parent as StackLayout; var parent2 = parent1.Parent as Grid; var parent3 = parent2.Parent as StackLayout; var parameter = ((Button)sender).CommandParameter as Answer; SubAnswerText = parameter.ResponseText; foreach (var child in parent3.Children) { var grid = child as Grid; var stack = grid.Children[0] as StackLayout; foreach (var item in stack.Children) { var button = item as Button; if (button.Text?.ToLower() != parameter?.ResponseText?.ToLower()) { button.BackgroundColor = Color.FromHex("#fff"); button.TextColor = Color.FromHex("#000"); } } } var parent4 = parent3.Parent as StackLayout; var paremt5 = parent4.Parent as Grid; var child0 = ((Grid)((Frame)paremt5.Children[0]).Content).Children[0] as Label; if (child0 != null) { CurrentActiveResponse = child0.Text; } var containerParent = (StackLayout)((FlexLayout)((StackLayout)(paremt5.Parent)).Parent).Parent; if (containerParent != null) { CurrentActiveQuestionId = ((Label)(containerParent.Children[0])).Text; if (string.IsNullOrEmpty(CurrentActiveQuestionId)) { CurrentActiveQuestionId = (((StackLayout)((StackLayout)(containerParent.Parent)).Parent)?.Children[0] as Label)?.Text; } } var child1 = (Entry)((Grid)((Frame)parent2.Children[1]).Content).Children[0]; if (child1 != null) { child1.Text = string.Empty; } if (SurveySummaries.Count(a => a.AnswerText.ToLower() == CurrentActiveResponse.ToLower()) == 0) { SurveySummaries.Add(new SurveySummary { QuestionGuid = CurrentActiveQuestionId, AnswerText = CurrentActiveResponse, SubAnswerText = SubAnswerText }); } else { SurveySummaries.Where(a => a.AnswerText.ToLower() == CurrentActiveResponse.ToLower()).ForEach(x => { x.SubAnswerText = SubAnswerText; }); } } catch (Exception) { } }