Class MarkupEditor
- Namespace
- Icy.Design
- Assembly
- IcyUI.Design.dll
Edits a DesignDocument: every edit changes the markup text minimally and is mirrored onto every live page built from it.
public sealed class MarkupEditor
- Inheritance
-
MarkupEditor
- Inherited Members
- Extension Methods
Remarks
Every edit is all-or-nothing. When it can't be made, or the live page rejects it (a value that doesn't convert, say), the method returns a failed EditResult and neither the text nor any page changed.
Edits to opaque parts of the markup (styles, resources, templates, anything under a property element such as
<Grid.RowDefinitions>) change the text only, and set NeedsReload.
Call the editor on the thread that owns the document's pages; other threads get an InvalidOperationException.
Properties
Document
Gets the document this editor changes.
public DesignDocument Document { get; }
Property Value
UndoStack
Gets the undo and redo history of this editor's edits.
public UndoStack UndoStack { get; }
Property Value
Methods
BeginTransaction(string)
Groups every edit made until the returned object is disposed into one undo step.
public IDisposable BeginTransaction(string description)
Parameters
descriptionstringWhat the step does, as UndoDescription reports it.
Returns
- IDisposable
The transaction; dispose it to close it. Transactions nest; only the outermost one records a step.
Exceptions
- ArgumentException
descriptionis null or empty.- ObjectDisposedException
The document's session was disposed.
ClearAttribute(NodeId, string)
Removes an attribute, so the property falls back to its style or default value.
public EditResult ClearAttribute(NodeId node, string name)
Parameters
Returns
- EditResult
The outcome; a success that changed nothing when the element has no such attribute.
Remarks
Exceptions
- ArgumentException
nameis null or empty.- ObjectDisposedException
The document's session was disposed.
InsertElement(NodeId, int, string)
Inserts an element written in markup as a content child of parent.
public EditResult InsertElement(NodeId parent, int index, string markup)
Parameters
parentNodeIdThe element to insert into.
indexintThe position among
parent's content children (property elements such as<Grid.RowDefinitions>don't count), from 0 to their count.markupstringExactly one element, such as
<Button Padding="12,6">OK</Button>.
Returns
- EditResult
The outcome; on success Node is the inserted element.
Remarks
Exceptions
- ArgumentNullException
markupis null.- ObjectDisposedException
The document's session was disposed.
MoveElement(NodeId, NodeId, int)
Moves an element to another parent, or to another position in the same parent. The live element keeps its identity and runtime state.
public EditResult MoveElement(NodeId node, NodeId newParent, int index)
Parameters
nodeNodeIdThe element to move. It can't be the root.
newParentNodeIdThe element to move it into. It can't be
nodeor inside it.indexintThe position among
newParent's content children, counted withoutnode.
Returns
- EditResult
The outcome.
Remarks
Exceptions
- ObjectDisposedException
The document's session was disposed.
RemoveElement(NodeId)
Removes an element and everything in it.
public EditResult RemoveElement(NodeId node)
Parameters
nodeNodeIdThe element to remove. It can't be the root.
Returns
- EditResult
The outcome.
Remarks
Exceptions
- ObjectDisposedException
The document's session was disposed.
SetAttribute(NodeId, string, string)
Sets an attribute, adding it when the element doesn't have it yet.
public EditResult SetAttribute(NodeId node, string name, string value)
Parameters
nodeNodeIdThe element.
namestringThe attribute name as written in markup:
Width,Grid.Row,x:Name.valuestringThe value as the property should receive it, or a markup extension such as
{Binding Path=Name}. It is escaped for the attribute's quote character; don't escape it yourself.
Returns
- EditResult
The outcome.
Remarks
Exceptions
- ArgumentException
nameis null or empty.- ArgumentNullException
valueis null.- ObjectDisposedException
The document's session was disposed.