public ChildListRow(FormViewer formViewer, FormField field) : base(formViewer, field) { HorizontalOptions = new LayoutOptions(LayoutAlignment.Fill, true); var titleBar = new Grid() { BackgroundColor = AppStyle.MenuBarBackground.ToXamFormsColor(), HeightRequest = 48, HorizontalOptions = new LayoutOptions(LayoutAlignment.Fill, true) }; titleBar.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star }); titleBar.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); _label = new Label() { FontSize = 20, Margin = new Thickness(10, 0, 0, 0), VerticalOptions = new LayoutOptions(LayoutAlignment.Center, false), TextColor = AppStyle.MenuBarForeground.ToXamFormsColor(), Text = field.Label }; _addImage = new IconButton() { Margin = new Thickness(0, 0, 20, 0), VerticalOptions = new LayoutOptions(LayoutAlignment.Center, false), IconKey = "fa-plus", WidthRequest = 48, HeightRequest = 48, FontSize = 22 }; _addImage.Clicked += _addImage_Clicked; _addImage.SetValue(Grid.ColumnProperty, 1); _childItemList = new StackLayout(); titleBar.Children.Add(_label); titleBar.Children.Add(_addImage); Children.Add(titleBar); Children.Add(_childItemList); }
public override void Refresh() { _childItemList.Children.Clear(); if (_childItems != null) { foreach (var child in _childItems) { var label = new Label(); label.Margin = new Thickness(15, 10, 10, 10); label.FontSize = 24; label.TextColor = Color.FromRgb(0x5B, 0x5B, 0x5B); label.Text = child.ToEntityHeader().Text; var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Star }); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); var boxView = new BoxView(); boxView.HeightRequest = 1; boxView.SetValue(Grid.ColumnSpanProperty, 3); boxView.SetValue(Grid.RowProperty, 1); boxView.Color = Color.SlateGray; var tapGenerator = new TapGestureRecognizer(); grid.BindingContext = child; tapGenerator.Tapped += Item_Tapped; var deleteButton = new IconButton() { IconKey = "fa-trash-o", FontSize = 20, TextColor = Color.Red, VerticalOptions = new LayoutOptions(LayoutAlignment.Center, false), Tag = child.ToEntityHeader().Id }; deleteButton.SetValue(Grid.ColumnProperty, 1); deleteButton.Clicked += DeleteButton_Clicked; var img = new Icon() { IconKey = "fa-chevron-right", Margin = new Thickness(2, 10, 30, 0), HeightRequest = 24, WidthRequest = 24, VerticalOptions = new LayoutOptions(LayoutAlignment.Center, false), }; img.SetValue(Grid.ColumnProperty, 2); grid.GestureRecognizers.Add(tapGenerator); grid.Children.Add(label); grid.Children.Add(boxView); grid.Children.Add(deleteButton); grid.Children.Add(img); _childItemList.Children.Add(grid); } } }