Class PropertyGridValueAdapter
- Namespace
- Icy.Data
- Assembly
- IcyUI.dll
Decides how a PropertyGrid reads and writes the properties it shows.
public class PropertyGridValueAdapter
- Inheritance
-
PropertyGridValueAdapter
- Derived
- Inherited Members
- Extension Methods
Remarks
The default adapter (Default) reads and writes the target's properties directly. Derive from this class to route edits elsewhere, for example into an undoable document, or to show some properties as raw text expressions instead of typed editors.
Every member is virtual and has a working default, so an adapter overrides only what it changes.
The default adapter offers Reset for a property that declares a DefaultValueAttribute and currently holds another value.
Properties
Default
Gets the adapter that reads and writes properties directly through reflection.
public static PropertyGridValueAdapter Default { get; }
Property Value
Methods
CanReset(PropertyGridEntry, object)
Determines whether the row shows a Reset button.
public virtual bool CanReset(PropertyGridEntry entry, object target)
Parameters
entryPropertyGridEntryThe row's property.
targetobjectThe object the grid shows.
Returns
- bool
The default: true when the property declares a DefaultValueAttribute, is writable, and currently holds another value.
GetExpression(PropertyGridEntry, object)
Gets the raw text to show instead of a typed editor, such as a {Binding} expression.
public virtual string? GetExpression(PropertyGridEntry entry, object target)
Parameters
entryPropertyGridEntryThe row's property.
targetobjectThe object the grid shows.
Returns
- string
The text, or null (the default) for a typed editor. A non-null text turns the row into a text box that commits through TrySetExpression(PropertyGridEntry, object, string) on Enter or when it loses focus.
GetValue(PropertyGridEntry, object)
Reads the value entry's editor shows.
public virtual object? GetValue(PropertyGridEntry entry, object target)
Parameters
entryPropertyGridEntryThe row's property.
targetobjectThe object the grid shows.
Returns
- object
The value; the default reads it with GetValue(object).
Reset(PropertyGridEntry, object)
Resets the property when the user presses the row's Reset button.
public virtual void Reset(PropertyGridEntry entry, object target)
Parameters
entryPropertyGridEntryThe row's property.
targetobjectThe object the grid shows.
Remarks
The default writes DefaultValue through TrySetValue(PropertyGridEntry, object, object?).
TrySetExpression(PropertyGridEntry, object, string)
Writes the text the user entered in an expression row.
public virtual bool TrySetExpression(PropertyGridEntry entry, object target, string text)
Parameters
entryPropertyGridEntryThe row's property.
targetobjectThe object the grid shows.
textstringThe entered text.
Returns
TrySetValue(PropertyGridEntry, object, object?)
Writes a value the user entered in entry's typed editor.
public virtual bool TrySetValue(PropertyGridEntry entry, object target, object? value)
Parameters
entryPropertyGridEntryThe row's property.
targetobjectThe object the grid shows.
valueobjectThe new value, already converted to PropertyType.