Table of Contents

Class MarkupPropertyAdapter

Namespace
Icy.Design.Editor.Panels
Assembly
IcyUI.Design.dll

Routes a PropertyGrid's edits of one markup element into its DesignDocument, so they're undoable and saved.

public sealed class MarkupPropertyAdapter : PropertyGridValueAdapter
Inheritance
MarkupPropertyAdapter
Inherited Members
Extension Methods

Remarks

  • Values are read from the live object, so styles, bindings and defaults show what's on screen.
  • A typed edit formats the value with MarkupValueFormatter and sets the attribute. Quick successive edits of one property coalesce into one undo step. A value with no markup form is refused, and LastError says why.
  • An attribute holding a markup extension ({Binding …}, {StaticResource …}) is shown and edited as text, so a typed editor never replaces it.
  • Reset removes the attribute, letting the style or default value apply again.

Constructors

MarkupPropertyAdapter(DesignDocument, NodeId, MarkupValueFormatter)

Initializes a new instance of the MarkupPropertyAdapter class.

public MarkupPropertyAdapter(DesignDocument document, NodeId node, MarkupValueFormatter formatter)

Parameters

document DesignDocument

The document the element belongs to.

node NodeId

The element.

formatter MarkupValueFormatter

Formats typed values as attribute text.

Exceptions

ArgumentNullException

document or formatter is null.

Properties

LastError

Gets why the last write was refused, or null when it succeeded.

public string? LastError { get; }

Property Value

string

Methods

CanReset(PropertyGridEntry, object)

Determines whether the row shows a Reset button.

public override bool CanReset(PropertyGridEntry entry, object target)

Parameters

entry PropertyGridEntry

The row's property.

target object

The 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 override string? GetExpression(PropertyGridEntry entry, object target)

Parameters

entry PropertyGridEntry

The row's property.

target object

The 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.

Reset(PropertyGridEntry, object)

Resets the property when the user presses the row's Reset button.

public override void Reset(PropertyGridEntry entry, object target)

Parameters

entry PropertyGridEntry

The row's property.

target object

The object the grid shows.

Remarks

TrySetExpression(PropertyGridEntry, object, string)

Writes the text the user entered in an expression row.

public override bool TrySetExpression(PropertyGridEntry entry, object target, string text)

Parameters

entry PropertyGridEntry

The row's property.

target object

The object the grid shows.

text string

The entered text.

Returns

bool

true when the text was accepted; on false (the default) the row is marked Invalid.

TrySetValue(PropertyGridEntry, object, object?)

Writes a value the user entered in entry's typed editor.

public override bool TrySetValue(PropertyGridEntry entry, object target, object? value)

Parameters

entry PropertyGridEntry

The row's property.

target object

The object the grid shows.

value object

The new value, already converted to PropertyType.

Returns

bool

true when the value was accepted.