menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class TextElement - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class TextElement

    Represents a TextElement which is used to display text content or annotations within diagram components.

    Inheritance
    System.Object
    CommonElement
    DiagramElement
    TextElement
    Inherited Members
    CommonElement.ActualSize
    CommonElement.Bounds
    CommonElement.CornerRadius
    CommonElement.DesiredSize
    CommonElement.Flip
    CommonElement.FlipMode
    CommonElement.Height
    CommonElement.HorizontalAlignment
    CommonElement.ID
    CommonElement.IsDirt
    CommonElement.Margin
    CommonElement.MaxHeight
    CommonElement.MaxWidth
    CommonElement.MinHeight
    CommonElement.MinWidth
    CommonElement.OffsetX
    CommonElement.OffsetY
    CommonElement.OuterBounds
    CommonElement.ParentID
    CommonElement.Pivot
    CommonElement.RelativeMode
    CommonElement.RotationAngle
    CommonElement.Shadow
    CommonElement.Style
    CommonElement.VerticalAlignment
    CommonElement.Visible
    CommonElement.Width
    Namespace: Syncfusion.Blazor.Diagram
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class TextElement : DiagramElement
    Remarks

    The TextElement supports text formatting and positioning options for creating rich text-based visualizations and annotations.

    This element inherits from DiagramElement and can be used within composite diagram elements.

    Examples

    This example demonstrates how to create and use a TextElement within a diagram node template.

    <SfDiagramComponent  SetNodeTemplate="SetTemplate">
    </SfDiagramComponent>    
    @code
    { 
        private CommonElement SetTemplate(IDiagramObject node)
        {
            if ((node as Node).ID == "node2")
            {
                DiagramCanvas container = new DiagramCanvas();
                TextElement textElement = new TextElement();
                textElement.Content = "node2content";
                container.Children.Add(textElement);
                return container;
            }
             return null;
        }
    }

    Constructors

    TextElement()

    Initializes a new instance of the TextElement with default styling properties.

    Declaration
    public TextElement()
    Remarks

    Initializes the Style property with default text styling including black color, Arial font, 12px size, center alignment, and transparent fill.

    TextElement(TextElement)

    Creates a new instance of the TextElement from the given TextElement.

    Declaration
    public TextElement(TextElement src)
    Parameters
    Type Name Description
    TextElement src

    A TextElement instance to copy from. If null, only the base constructor is called and properties retain their default values.

    Remarks

    Performs a deep copy of the source TextElement, including Syncfusion.Blazor.Diagram.TextElement.CanMeasure, Syncfusion.Blazor.Diagram.TextElement.CanConsiderBounds, and cloned Syncfusion.Blazor.Diagram.TextElement.Hyperlink settings when present.

    When src is null, properties retain their default values.

    Properties

    Content

    Gets or sets the content of the text element that is to be displayed in the TextElement.

    Declaration
    public string Content { get; set; }
    Property Value
    Type Description
    System.String

    A System.String representing the text content to be rendered. The default value is null.

    Remarks

    Setting this property will set the text content of the TextElement.

    Examples

    The following example demonstrates how to set the content of a TextElement.

    <SfDiagramComponent SetNodeTemplate="SetTemplate">
    </SfDiagramComponent>    
    @code
    { 
        private CommonElement SetTemplate(IDiagramObject node)
        {
            if ((node as Node).ID == "node2")
            {
                DiagramCanvas container = new DiagramCanvas();
                TextElement textElement = new TextElement();
                textElement.Content = "node2content";
                return container;
            }
             return null;
        }
    }

    Methods

    Clone()

    Creates a new object that is a copy of the current TextElement.

    Declaration
    public override object Clone()
    Returns
    Type Description
    System.Object

    A new TextElement instance that is a deep copy of the current text element, including all properties and content.

    Overrides
    DiagramElement.Clone()
    Remarks

    This method performs a deep copy, creating an independent TextElement instance with identical properties and content.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved