public ListViewItem() { ControlValidation = null; Content = new Grid { ColumnSpacing = 0, HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Center, }; }
protected void RecreatControl() { _grid.Children.Clear(); _grid.RowDefinitions.Clear(); _grid.ColumnDefinitions.Clear(); ControlValidation = null; var listControl = GetParentListView(); if (listControl == null) { return; } var domainModelType = listControl.GetListItemType(); _grid.ColumnSpacing = 0; _grid.Padding = new Thickness(25, 5, 25, 5); var props = AttributeHelper.GetPropertyAttributes <AutoFormsListItemAttribute>(domainModelType); ControlValidation controlValidation = new ControlValidation(() => { _grid.ForceLayout(); }); foreach (var p in props) { var property = p.Item1; var attribute = ControlBase.GetFilteredAttribute(listControl.Filter, p.Item2); if (property == null || attribute == null) { continue; } _grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(attribute.Value, attribute.GridType) }); var v = CreateControlView(property, attribute, listControl); Grid.SetColumn(v, _grid.ColumnDefinitions.Count - 1); _grid.Children.Add(v); var validations = property.GetAttributes <AutoFormsValidationAttribute>(); if (validations != null && validations.Length > 0) { foreach (var validation in validations) { controlValidation.AddValidation(validation, v, string.IsNullOrWhiteSpace(attribute.Label) ? attribute.Placeholder : attribute.Label); } } } CreateActionButtons(listControl); if (controlValidation.Size > 0) { _grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); Grid.SetRow(controlValidation, 1); Grid.SetColumnSpan(controlValidation, _grid.ColumnDefinitions.Count); _grid.Children.Add(controlValidation); ControlValidation = controlValidation; } //_grid.DebugGrid(Color.Red); }