Class SfRichTextEditor
Represents a rich text editor control that provides HTML editing capabilities with toolbar support.
Implements
Inherited Members
Namespace: Syncfusion.Maui.RichTextEditor
Assembly: Syncfusion.Maui.RichTextEditor.dll
Syntax
public class SfRichTextEditor : SfView, IDrawableLayout, IDrawable, IAbsoluteLayout, ILayout, IView, IElement, ITransform, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISafeAreaView, IPadding, ICrossPlatformLayout, IVisualTreeElement, ISemanticsProvider, IDisposable, IParentThemeElement, IThemeElement
Constructors
SfRichTextEditor()
Initializes a new instance of the SfRichTextEditor class.
Declaration
public SfRichTextEditor()
Fields
BorderColorProperty
Identifies the BorderColor bindable property.
Declaration
public static readonly BindableProperty BorderColorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
BorderThicknessProperty
Identifies the BorderThickness bindable property.
Declaration
public static readonly BindableProperty BorderThicknessProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
DefaultFontFamilyProperty
Identifies the DefaultFontFamily bindable property.
Declaration
public static readonly BindableProperty DefaultFontFamilyProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
DefaultFontSizeProperty
Identifies the DefaultFontSize bindable property.
Declaration
public static readonly BindableProperty DefaultFontSizeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
DefaultTextColorProperty
Identifies the DefaultTextColor bindable property.
Declaration
public static readonly BindableProperty DefaultTextColorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
EditorBackgroundColorProperty
Identifies the EditorBackgroundColor bindable property.
Declaration
public static readonly BindableProperty EditorBackgroundColorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
EnableAutoSizeProperty
Identifies the EnableAutoSize bindable property.
Declaration
public static readonly BindableProperty EnableAutoSizeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
EnableWordWrapProperty
Identifies the EnableWordWrap bindable property.
Declaration
public static readonly BindableProperty EnableWordWrapProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
FontFamiliesProperty
Identifies the FontFamilies bindable property.
Declaration
public static readonly BindableProperty FontFamiliesProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
HtmlTextProperty
Identifies the HtmlText bindable property.
Declaration
public static readonly BindableProperty HtmlTextProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
IsFocusedProperty
Identifies the IsFocused bindable property.
Declaration
public static readonly BindableProperty IsFocusedProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
PlaceholderColorProperty
Identifies the PlaceholderColor bindable property.
Declaration
public static readonly BindableProperty PlaceholderColorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
PlaceholderFontFamilyProperty
Identifies the PlaceholderFontFamily bindable property.
Declaration
public static readonly BindableProperty PlaceholderFontFamilyProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
PlaceholderFontSizeProperty
Identifies the PlaceholderFontSize bindable property.
Declaration
public static readonly BindableProperty PlaceholderFontSizeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
PlaceholderProperty
Identifies the Placeholder bindable property.
Declaration
public static readonly BindableProperty PlaceholderProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ReadOnlyProperty
Identifies the ReadOnly bindable property.
Declaration
public static readonly BindableProperty ReadOnlyProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ShowToolbarProperty
Identifies the ShowToolbar bindable property.
Declaration
public static readonly BindableProperty ShowToolbarProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TableCellColorProperty
Identifies the TableCellColor bindable property.
Declaration
public static readonly BindableProperty TableCellColorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TableCellSelectionColorProperty
Identifies the TableCellSelectionColor bindable property.
Declaration
public static readonly BindableProperty TableCellSelectionColorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TextProperty
Identifies the Text bindable property.
Declaration
public static readonly BindableProperty TextProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ToolbarItemsProperty
Identifies the ToolbarItems bindable property. This property represents the collection of toolbar items used in the editor. The default is an empty collection.
Declaration
public static readonly BindableProperty ToolbarItemsProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ToolbarPositionProperty
Identifies the ToolbarPosition bindable property.
Declaration
public static readonly BindableProperty ToolbarPositionProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ToolbarSettingsProperty
Identifies the ToolbarSettings bindable property. This property defines the settings for the toolbar's appearance and behavior.
Declaration
public static readonly BindableProperty ToolbarSettingsProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Properties
BorderColor
Gets or sets the BorderColor.
Declaration
public Color BorderColor { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Color | The BorderColor color for the editor's BorderColor. |
BorderThickness
Gets or sets the Border thickness.
Declaration
public double BorderThickness { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The thickness of the editor's border. |
DefaultFontFamily
Gets or sets the default font family for new text.
Declaration
public string DefaultFontFamily { get; set; }
Property Value
Type | Description |
---|---|
System.String | The default font family name. |
DefaultFontSize
Gets or sets the default font size for new text.
Declaration
public double DefaultFontSize { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The default font size in pixels. |
DefaultTextColor
Gets or sets the default text color for the editor.
Declaration
public Color DefaultTextColor { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Color | The default color for text entered by the user. |
EditorBackgroundColor
Gets or sets the Background Color for the editor.
Declaration
public Color EditorBackgroundColor { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Color | The Background Color of the control. |
EnableAutoSize
Gets or sets a value indicating whether the editor is read-only.
Declaration
public bool EnableAutoSize { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the editor is read-only; otherwise, false. |
EnableWordWrap
Gets or sets the word wrap mode in the editor.
Declaration
public bool EnableWordWrap { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The word wrap mode. Default is Normal. |
FontFamilies
Gets or sets the collection of font family styles available for new text.
Declaration
public IList<RichTextEditorFontStyle> FontFamilies { get; set; }
Property Value
Type |
---|
System.Collections.Generic.IList<RichTextEditorFontStyle> |
HtmlText
Gets or sets the html content to the editor.
Declaration
public string HtmlText { get; set; }
Property Value
Type | Description |
---|---|
System.String | The Html text as a string. |
IsFocused
Gets a value indicating whether the editor currently has focus.
Declaration
public bool IsFocused { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the editor has focus; otherwise, false. |
Placeholder
Gets or sets the placeholder text displayed when the editor is empty.
Declaration
public string Placeholder { get; set; }
Property Value
Type | Description |
---|---|
System.String | The placeholder text. |
PlaceholderColor
Gets or sets the text color of the placeholder.
Declaration
public Color PlaceholderColor { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Color | The color of the placeholder text. |
PlaceholderFontFamily
Gets or sets the font family for the placeholder text.
Declaration
public string PlaceholderFontFamily { get; set; }
Property Value
Type | Description |
---|---|
System.String | The font family name for the placeholder. |
PlaceholderFontSize
Gets or sets the font size for the placeholder text.
Declaration
public double PlaceholderFontSize { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The font size in pixels for the placeholder. |
ReadOnly
Gets or sets a value indicating whether the editor is read-only.
Declaration
public bool ReadOnly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the editor is read-only; otherwise, false. |
ShowToolbar
Gets or sets a value indicating whether the toolbar is visible.
Declaration
public bool ShowToolbar { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the toolbar is visible; otherwise, false. |
TableCellColor
Gets or sets the Table cell color for the editor.
Declaration
public Color TableCellColor { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Color | The Table Cell Color of the control. |
TableCellSelectionColor
Gets or sets the Table cell selection color for the editor.
Declaration
public Color TableCellSelectionColor { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Color | The Table Cell Selection Color of the control. |
Text
Gets or sets the plain text content of the editor without HTML formatting.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | The plain text content as a string. |
ToolbarItems
Gets or sets the collection of toolbar items used in the editor.
Declaration
public RichTextEditorToolBarItemCollection ToolbarItems { get; set; }
Property Value
Type |
---|
RichTextEditorToolBarItemCollection |
ToolbarPosition
Gets or sets the position of the toolbar.
Declaration
public RichTextEditorToolbarPosition ToolbarPosition { get; set; }
Property Value
Type | Description |
---|---|
RichTextEditorToolbarPosition | The toolbar position. |
ToolbarSettings
Gets or sets the appearance settings for the toolbar.
Declaration
public RichTextEditorToolbarSettings ToolbarSettings { get; set; }
Property Value
Type |
---|
RichTextEditorToolbarSettings |
Methods
AlignCenter()
Aligns the current paragraph or selection to the center.
Declaration
public void AlignCenter()
AlignJustify()
Justifies the current paragraph or selection.
Declaration
public void AlignJustify()
AlignLeft()
Aligns the current paragraph or selection to the left.
Declaration
public void AlignLeft()
AlignRight()
Aligns the current paragraph or selection to the right.
Declaration
public void AlignRight()
ApplyFontFamily(String)
Sets the font family for the selected text or cursor position.
Declaration
public void ApplyFontFamily(string fontFamily)
Parameters
Type | Name | Description |
---|---|---|
System.String | fontFamily | The font family name to apply. |
ApplyFontSize(Double)
Sets the font size for the selected text or cursor position.
Declaration
public void ApplyFontSize(double fontSize)
Parameters
Type | Name | Description |
---|---|---|
System.Double | fontSize | The font size in pixels. |
ApplyHighlightColor(Color)
Applies background color formatting to the selected text or at cursor position.
Declaration
public void ApplyHighlightColor(Color color)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Maui.Graphics.Color | color | The background color to apply to the text. |
ApplyParagraphFormat(RichTextEditorParagraphFormat)
Sets the paragraph format as paragraph, heading (1-4), quotation or code block.
Declaration
public void ApplyParagraphFormat(RichTextEditorParagraphFormat heading)
Parameters
Type | Name | Description |
---|---|---|
RichTextEditorParagraphFormat | heading | The value may be paragraph, heading (1-4), quotation or code block. |
ApplyTextColor(Color)
Applies text color formatting to the selected text or at cursor position.
Declaration
public void ApplyTextColor(Color color)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Maui.Graphics.Color | color | The color to apply to the text. |
DecreaseIndent()
Decreases the indentation level of the current paragraph or selection.
Declaration
public void DecreaseIndent()
Dispose()
Releases all resources used by the SfRichTextEditor.
Declaration
public void Dispose()
Dispose(Boolean)
Releases the unmanaged resources used by the SfRichTextEditor and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | True to release both managed and unmanaged resources; false to release only unmanaged resources. |
EditHyperlink(String, String, String)
Edits an existing hyperlink at the current selection or cursor position.
Declaration
public void EditHyperlink(string text, string oldUrl, string newUrl)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to display for the hyperlink. |
System.String | oldUrl | The URL for the hyperlink. |
System.String | newUrl | The URL for the hyperlink. |
Focus()
Focuses the editor programmatically.
Declaration
public void Focus()
GetSelectedText()
Gets the Selected Text.
Declaration
public Task<string> GetSelectedText()
Returns
Type |
---|
System.Threading.Tasks.Task<System.String> |
IncreaseIndent()
Increases the indentation level of the current paragraph or selection.
Declaration
public void IncreaseIndent()
InsertHyperlink(String, String)
Inserts a hyperlink at the current cursor position or replaces the current selection.
Declaration
public void InsertHyperlink(string displayText, string url)
Parameters
Type | Name | Description |
---|---|---|
System.String | displayText | The text to display for the hyperlink. |
System.String | url | The URL for the hyperlink. |
InsertHyperlinkAsync(String, String, String)
Inserts a hyperlink at the current cursor position or replaces selected text.
Declaration
public Task<bool> InsertHyperlinkAsync(string url, string text, string title = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | The URL of the hyperlink. |
System.String | text | The display text of the hyperlink. |
System.String | title | The optional title attribute of the hyperlink. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | A task that represents the asynchronous operation. The task result contains true if successful. |
InsertImage(RichTextEditorImageSource)
Increases the image at the currnt cursor position.
Declaration
public void InsertImage(RichTextEditorImageSource imageSource)
Parameters
Type | Name | Description |
---|---|---|
RichTextEditorImageSource | imageSource |
InsertTable(Int32, Int32)
Insert the table
Declaration
public void InsertTable(int rowCount, int columnCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowCount | |
System.Int32 | columnCount |
MoveCursorToEnd()
Moves the cursor to the end of the content in the editor.
Declaration
public void MoveCursorToEnd()
MoveCursorToStart()
Moves the cursor to the start of the content in the editor.
Declaration
public void MoveCursorToStart()
OnBindingContextChanged()
Declaration
protected override void OnBindingContextChanged()
Overrides
OnHistoryStateChanged()
Raises the HistoryStateChanged event.
Declaration
protected virtual void OnHistoryStateChanged()
OnPropertyChanged(String)
Override the OnPropertyChanged to handle MinimumHeightRequest changes
Declaration
protected override void OnPropertyChanged(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName |
OnSizeAllocated(Double, Double)
Called when the size of the control is allocated.
Declaration
protected override void OnSizeAllocated(double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | width | The allocated width. |
System.Double | height | The allocated height. |
Redo()
Performs a redo operation.
Declaration
public void Redo()
RemoveHyperlink(String, String)
Removes the hyperlink at the current cursor position while preserving the text.
Declaration
public void RemoveHyperlink(string text, string Url)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | |
System.String | Url |
ToggleBold()
Applies bold formatting to the selected text or at cursor position.
Declaration
public void ToggleBold()
ToggleBulletList()
Toggles bullet list formatting for the current paragraph or selection.
Declaration
public void ToggleBulletList()
ToggleItalic()
Applies italic formatting to the selected text or at cursor position.
Declaration
public void ToggleItalic()
ToggleNumberedList()
Toggles numbered list formatting for the current paragraph or selection.
Declaration
public void ToggleNumberedList()
ToggleStrikethrough()
Applies strikethrough formatting to the selected text or at cursor position.
Declaration
public void ToggleStrikethrough()
ToggleSubscript()
Applies subscript formatting to the selected text or at cursor position.
Declaration
public void ToggleSubscript()
ToggleSuperscript()
Applies superscript formatting to the selected text or at cursor position.
Declaration
public void ToggleSuperscript()
ToggleUnderline()
Applies underline formatting to the selected text or at cursor position.
Declaration
public void ToggleUnderline()
Undo()
Performs an undo operation.
Declaration
public void Undo()
Unfocus()
Removes focus from the editor.
Declaration
public void Unfocus()
Events
Focused
Occurs when the editor gains focus.
Declaration
public event EventHandler Focused
Event Type
Type |
---|
System.EventHandler |
FormatChanged
Occurs when the formatting status changes.
Declaration
public event EventHandler<RichTextEditorFormatChangedEventArgs> FormatChanged
Event Type
Type |
---|
System.EventHandler<RichTextEditorFormatChangedEventArgs> |
HyperlinkClicked
Occurs when a hyperlink is selected in the editor.
Declaration
public event EventHandler<RichTextEditorHyperlinkClickedEventArgs> HyperlinkClicked
Event Type
Type |
---|
System.EventHandler<RichTextEditorHyperlinkClickedEventArgs> |
ImageRequested
Image inserted event occurs when image button in toolbar is clicked.
Declaration
public event EventHandler<RichTextEditorImageRequestedEventArgs> ImageRequested
Event Type
Type |
---|
System.EventHandler<RichTextEditorImageRequestedEventArgs> |
TextChanged
Occurs when text content in the editor changes.
Declaration
public event EventHandler<RichTextEditorTextChangedEventArgs> TextChanged
Event Type
Type |
---|
System.EventHandler<RichTextEditorTextChangedEventArgs> |
Unfocused
Occurs when the editor loses focus.
Declaration
public event EventHandler Unfocused
Event Type
Type |
---|
System.EventHandler |