private void OnAutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) { var context = new AutoGridColumnContext(AssociatedObject, e, (PropertyDescriptor)e.PropertyDescriptor); if (!IsBrowsable(context)) { e.Cancel = true; return; } var ignoreProperties = new [] { nameof(IHasDirtyFlag.IsDirty), nameof(ISelectable.IsSelected), nameof(INotifyDataErrorInfo.HasErrors) }; if (ignoreProperties.Contains(e.PropertyName) || context.GetAttribute <GroupByAttribute>() != null || typeof(ICollection).IsAssignableFrom(context.Property.PropertyType)) { e.Cancel = true; return; } foreach (var columnBehavior in _columnBehaviors) { columnBehavior.Attach(context); } }
private bool IsBrowsable(AutoGridColumnContext context) { _showOnlyBrowsable = _showOnlyBrowsable ?? context.Property.ComponentType.GetCustomAttributes(false) .FirstOrDefault(x => x is ShowOnlyBrowsableAttribute b && b.OnlyBrowsable) != null; var browsable = context.GetAttribute <BrowsableAttribute>(); if (_showOnlyBrowsable.Value && browsable?.Browsable != true || !_showOnlyBrowsable.Value && browsable?.Browsable == false) { return(false); } return(true); }