Class TextElement
A text shape element for displaying standalone text on the canvas.
public class TextElement : ShapeElement, ICanvasElement, INotifyPropertyChanged
- Inheritance
-
TextElement
- Implements
- Inherited Members
Examples
// Create a diagram title
var title = new TextElement("title-1")
{
Position = new Point(50, 20),
Text = "System Architecture",
FontSize = 24,
FontWeight = FontWeight.Bold,
Fill = "#2c3e50"
};
// Create an annotation
var note = new TextElement("note-1")
{
Position = new Point(200, 300),
Text = "TODO: Add error handling",
FontSize = 12,
FontStyle = FontStyle.Italic,
Fill = "#e74c3c"
};
Remarks
TextElement is useful for: - Annotations and comments - Diagram titles and labels - Swimlane headers - Free-form notes
Unlike node labels, TextElement exists independently and can be positioned anywhere on the canvas without being attached to a node.
Constructors
TextElement()
Creates a new text element with a generated ID.
public TextElement()
TextElement(string)
Creates a new text element with the specified ID.
public TextElement(string id)
Parameters
idstringThe unique identifier for this text element.
Properties
FontFamily
Gets or sets the font family name.
public string FontFamily { get; set; }
Property Value
FontSize
Gets or sets the font size in points.
public double FontSize { get; set; }
Property Value
FontStyle
Gets or sets the font style (normal, italic, etc.).
public FontStyle FontStyle { get; set; }
Property Value
FontWeight
Gets or sets the font weight.
public FontWeight FontWeight { get; set; }
Property Value
MaxWidth
Gets or sets the maximum width for text wrapping. Null means no wrapping - text extends as needed.
public double? MaxWidth { get; set; }
Property Value
Text
Gets or sets the text content to display.
public string Text { get; set; }
Property Value
TextAlignment
Gets or sets the text alignment within the element bounds.
public TextAlignment TextAlignment { get; set; }
Property Value
Type
Gets the type identifier for this element.
public override string Type { get; }
Property Value
Remarks
Used by renderer registries to select the appropriate renderer. For nodes, this typically comes from the node definition's Type property. For shapes, this identifies the shape type (line, rectangle, text, etc.).