Property Grid
Description
PropertyGrid<T> reflects over a typed object's public properties at render time and generates a two-way-bound editing form without any markup. Each property is mapped to an input control based on its declared type:
| Property type | Control |
|---|---|
string |
TextBox (single-line) or TextArea (when [PropertyGridMultiline] or .Multiline(...) is set) |
bool |
Toggle |
enum |
Single-select Dropdown populated from Enum.GetValues |
int, long, short, byte, and unsigned variants |
NumberPicker |
double, float, decimal |
Numeric TextBox (type="number" step="any") |
DateTime / DateTime? |
DateTimePicker |
Color |
ColorPicker |
| Nested class or struct | Recursive Expander section containing another PropertyGrid pass |
| Anything else | Read-only TextBox showing .ToString() |
Edits write directly back to the bound object and notify subscribers via AsObservable() or OnChange(...). Read-only mode (ReadOnly() with no arguments) renders the whole grid non-editable; passing property names restricts read-only to those specific fields. Per-property behaviour (label, description, order, read-only, multiline, validation) is set through [PropertyGrid*] attributes on the class, the fluent config API on the PropertyGrid<T> instance, or both — attributes are applied first and the fluent config wins when both are present.
Properties without a setter are automatically treated as read-only. Properties marked [PropertyGridIgnore] are skipped entirely. Display order defaults to declaration order; it can be overridden with [PropertyGridOrder(n)] or .Order(name, n) (lower values appear first).
Use PropertyGrid<T> when you need a generic editor for a settings object, a form that tracks a typed model, or a debug inspector for any class instance — without writing per-property form code.
Factory method: UI.PropertyGrid<T>(instance) or the non-generic UI.PropertyGrid(instance) (returns PropertyGrid<object>).
API reference
public sealed class PropertyGridLabelAttribute : AttributeMarks a property with a friendly label for the PropertyGrid{T}. Attribute support is best-effort (it depends on reflection metadata being available); the fluent config API is always honored.
- Namespace
- Tesserae
- Inheritance
- Attribute → PropertyGridLabelAttribute
Constructors
| Name | Description |
|---|---|
| PropertyGridLabelAttribute | Initializes a new instance of the PropertyGridLabelAttribute class. |
Properties
| Name | Description |
|---|---|
| Label | The display label. |
public sealed class PropertyGridDescriptionAttribute : AttributeMarks a property with a helper description for the PropertyGrid{T}.
- Namespace
- Tesserae
- Inheritance
- Attribute → PropertyGridDescriptionAttribute
Constructors
| Name | Description |
|---|---|
| PropertyGridDescriptionAttribute | Initializes a new instance of the PropertyGridDescriptionAttribute class. |
Properties
| Name | Description |
|---|---|
| Description | The description text. |
public sealed class PropertyGridOrderAttribute : AttributeSets the display order of a property in the PropertyGrid{T} (lower comes first).
- Namespace
- Tesserae
- Inheritance
- Attribute → PropertyGridOrderAttribute
Constructors
| Name | Description |
|---|---|
| PropertyGridOrderAttribute | Initializes a new instance of the PropertyGridOrderAttribute class. |
Properties
| Name | Description |
|---|---|
| Order | The sort order. |
public sealed class PropertyGridReadOnlyAttribute : AttributeMarks a property as read-only in the PropertyGrid{T}.
- Namespace
- Tesserae
- Inheritance
- Attribute → PropertyGridReadOnlyAttribute
public sealed class PropertyGridIgnoreAttribute : AttributeHides a property from the PropertyGrid{T}.
- Namespace
- Tesserae
- Inheritance
- Attribute → PropertyGridIgnoreAttribute
public sealed class PropertyGridMultilineAttribute : AttributeRenders a string property as a multi-line TextArea in the PropertyGrid{T}.
- Namespace
- Tesserae
- Inheritance
- Attribute → PropertyGridMultilineAttribute
public sealed class PropertyGridFieldOptionsPer-property display / behaviour options resolved from attributes and the fluent config API.
- Namespace
- Tesserae
Fields
| Name | Description |
|---|---|
| Label | Overrides the field label. |
| Description | A helper description shown beneath the editor. |
| Order | Explicit display order (lower comes first). |
| ReadOnly | Whether the field is read-only. |
| Ignore | Whether the field is hidden. |
| Multiline | Whether a string field is rendered multi-line. |
| Validate | A validation function returning an error message (or null/empty when valid) for the current value. |
public string DescriptionA helper description shown beneath the editor.
public bool MultilineWhether a string field is rendered multi-line.
public sealed class PropertyGrid<T> : IComponentA metadata-driven property editor. Given a typed object it reflects over its public properties and auto-generates a two-way-bound editing form, mapping each property type to an existing Tesserae input (string → TextBox/TextArea, numbers → NumberPicker, bool → Toggle, enum → Dropdown, DateTime → DateTimePicker, Color → ColorPicker, nested objects → a recursive grouped Expander section). Edits flow straight back onto the bound object and are surfaced via AsObservable / OnChange. Per-property label/description/order/read-only overrides come from attributes or the fluent config API, and validation integrates with the existing Validator.
- Namespace
- Tesserae
- Implements
- IComponent
Constructors
| Name | Description |
|---|---|
| PropertyGrid | Initializes a new instance of the PropertyGrid{T} class bound to instance. |
Methods
| Name | Description |
|---|---|
| AsObservable | Returns an observable that fires (with the bound instance) whenever any field is edited. |
| OnChange | Registers a callback invoked (with the bound instance) whenever any field is edited. |
| WithValidator | Wires the grid's validatable editors to the supplied Validator. |
| Label | Overrides the label shown for a property. |
| Description | Sets a helper description shown beneath a property's editor. |
| Order | Sets the display order of a property (lower comes first). |
| ReadOnly | Marks fields as read-only. When restrictTo is null or empty the whole grid becomes a read-only view (every field shows its value but cannot be edited); otherwise only the named properties are made read-only. Read-only fields do not flow edits back to the bound object. |
| Ignore | Hides one or more properties. |
| Multiline | Renders a string property as a multi-line text area. |
| Validate | Adds a validation rule for a property. The function receives the property's current value and returns an error message (or null/empty when valid). Integrates with the configured Validator. |
| Render | Renders the component's root HTML element. |
public IObservable<T> AsObservable()Returns an observable that fires (with the bound instance) whenever any field is edited.
public PropertyGrid<T> OnChange(Action<T> onChange)Registers a callback invoked (with the bound instance) whenever any field is edited.
public PropertyGrid<T> WithValidator(Validator validator)Wires the grid's validatable editors to the supplied Validator.
public PropertyGrid<T> Label(string propertyName, string label)Overrides the label shown for a property.
public PropertyGrid<T> Description(string propertyName, string description)Sets a helper description shown beneath a property's editor.
public PropertyGrid<T> Order(string propertyName, int order)Sets the display order of a property (lower comes first).
public PropertyGrid<T> ReadOnly(params string[] restrictTo)Marks fields as read-only. When restrictTo is null or empty the whole grid becomes a read-only view (every field shows its value but cannot be edited); otherwise only the named properties are made read-only. Read-only fields do not flow edits back to the bound object.
public PropertyGrid<T> Ignore(params string[] propertyNames)Hides one or more properties.
public PropertyGrid<T> Multiline(string propertyName)Renders a string property as a multi-line text area.
public PropertyGrid<T> Validate(string propertyName, Func<object, string> validate)Adds a validation rule for a property. The function receives the property's current value and returns an error message (or null/empty when valid). Integrates with the configured Validator.