private void RenderYesNo() { var stk = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal }; var title = new Label() { FontSize = 14, Text = Unite.Name, TextColor = Color.Black, VerticalOptions = LayoutOptions.Center }; stk.Children.Add(title); var input = new ToggleBox() { HeightRequest = 25, WidthRequest = 25, CheckedImage = "ic_checked_box_black", UnCheckedImage = "ic_unchecked_box_black" }; input.SetBinding(ToggleBox.IsToggledProperty, new Binding("Value", BindingMode.TwoWay, converter: new IntToBoolConverter(), source: Unite)); if (!string.IsNullOrWhiteSpace(Unite.Value) && ConvertToBool(Unite.Value, out bool value)) { input.IsToggled = value; } stk.Children.Add(input); Content = stk; }
private void RenderMultiChoice() { var stk = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand }; var title = new Label() { FontSize = 14, Text = Unite.Name, TextColor = Color.Black, VerticalOptions = LayoutOptions.Center }; stk.Children.Add(title); string[] choice = null; if (!string.IsNullOrWhiteSpace(Unite.Value)) { choice = Unite.Value.Split(';'); } foreach (var ui in Unite.UniteItems) { var stk2 = new StackLayout() { Orientation = StackOrientation.Horizontal }; var input2 = new ToggleBox() { HeightRequest = 25, WidthRequest = 25, CheckedImage = "ic_checked_box_black", UnCheckedImage = "ic_unchecked_box_black" }; input2.SetBinding(ToggleBox.IsToggledProperty, new Binding("Selected", BindingMode.TwoWay, source: ui)); if (choice != null && choice.Any(c => c.Trim().Equals(ui.Value.Trim()))) { input2.IsToggled = true; } stk2.Children.Add(input2); var title2 = new Label() { FontSize = 14, Text = ui.Value, TextColor = Color.Black, VerticalOptions = LayoutOptions.Center }; stk2.Children.Add(title2); stk.Children.Add(stk2); } Content = stk; }
private void RenderMultiChoice() { var stk = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand }; var title = new Label() { FontSize = 14, Text = Unite.Name, TextColor = Color.Black, VerticalOptions = LayoutOptions.Center }; stk.Children.Add(title); string[] choice = null; if (!string.IsNullOrWhiteSpace(Unite.Value)) { if (Unite.Value.Length > 3 && (Unite.Value.Contains(",") || Unite.Value.Contains(";"))) { string[] dataItem; if (Unite.Value.Contains(",")) { dataItem = Unite.Value.Split(','); } else { dataItem = Unite.Value.Split(';'); } int n; if (dataItem != null && dataItem.Length > 0 && int.TryParse(dataItem[0], out n)) { var temp = ""; for (int i = 0; i < dataItem.Length; i++) { var uniteItem = App.LocalDb.Table <UniteItem>().ToList().FirstOrDefault(uni => uni.ServerId == int.Parse(dataItem[i])); temp += uniteItem.Value + ";"; } if (temp.Length > 1) { Unite.Value = temp; } } } choice = Unite.Value.Split(';'); } foreach (var ui in Unite.UniteItems) { var stk2 = new StackLayout() { Orientation = StackOrientation.Horizontal, }; var input2 = new ToggleBox() { HeightRequest = 25, WidthRequest = 25, CheckedImage = "ic_checked_box_black", UnCheckedImage = "ic_unchecked_box_black" }; input2.SetBinding(ToggleBox.IsToggledProperty, new Binding("Selected", BindingMode.TwoWay, source: ui)); if (choice != null && choice.Any(c => c.Trim().Equals(ui.Value.Trim()))) { input2.IsToggled = true; } stk2.Children.Add(input2); var title2 = new Label() { FontSize = 14, Text = ui.Value, TextColor = Color.Black, VerticalOptions = LayoutOptions.Center }; stk2.Children.Add(title2); stk.Children.Add(stk2); } Content = stk; }