/// <summary> /// Updates the framework element based on the given property change. /// Subclasses can override this method, but typically they can override /// individual methods for each particular type of property change. /// </summary> /// <param name="change">The property change.</param> protected virtual void UpdateElement(PropertyChange change) { if (property == null) { return; } property.Row = row; if (change.IncludesEditable()) { UpdateEditability(); } if (change.IncludesVisible()) { UpdateVisibility(); } if (change.IncludesRequired() || change.IncludesEditable()) { UpdateRequired(); } if (change.IncludesValidation() || change.IncludesEditable() || change.IncludesVisible()) { UpdateValidation(); } }
/// <summary> /// Get a list of property states for the given property using current descriptions. /// </summary> /// <param name="property">The data property to get the states for.</param> /// <param name="states">The combination of property states to return.</param> /// <param name="row">Specific data row for list objects, or null for regular data objects.</param> public virtual IEnumerable <string> GetStates(DataProperty property, PropertyChange states, DataRow row) { var state = new HashSet <string>(); if (property.Visible) { if (property.Editable) { if (property.Required && states.IncludesRequired()) { state.Add(Required); } if (property.Modified == true && states.IncludesValue()) { state.Add(Modified); } if (states.IncludesValidation()) { var err = property.GetValidationErrors(row); if (err?.Errors != null) { if (err.HasErrors()) { state.Add(Invalid); } else if (err.Errors.Any(e => e.Severity == ErrorSeverity.Warning)) { state.Add(Warning); } else if (err.Errors.Any() || // info? // don't mark as valid blank or enum and bool properties, since it's not helpful !property.IsNull(row) && !(property is EnumProperty) && !(property is BooleanProperty)) { state.Add(Valid); } } } } else if (states.IncludesEditable()) { state.Add(Readonly); } } else if (states.IncludesVisible()) { state.Add(Hidden); } return(state); }
/// <summary> /// Updates the framework element based on the given property change. /// Subclasses can override this method, but typically they can override /// individual methods for each particular type of property change. /// </summary> /// <param name="change">The property change.</param> protected virtual void UpdateElement(PropertyChange change) { if (property == null) return; property.Row = row; if (change.IncludesEditable()) UpdateEditability(); if (change.IncludesVisible()) UpdateVisibility(); if (change.IncludesRequired() || change.IncludesEditable()) UpdateRequired(); if (change.IncludesValidation() || change.IncludesEditable() || change.IncludesVisible()) UpdateValidation(); }