Class SfRichTextEditor
Represents a RichTextEditor class which is used for create and modify the RichTextEditor.
Inheritance
Namespace: Syncfusion.XForms.RichTextEditor
Assembly: Syncfusion.SfRichTextEditor.XForms.dll
Syntax
public class SfRichTextEditor : ContentView, IParentThemeElement, IThemeElement
Constructors
SfRichTextEditor()
Initializes a new instance of the SfRichTextEditor class.
Declaration
public SfRichTextEditor()
Fields
AutoSizeProperty
Indicates the AutoSize property.
Declaration
public static readonly BindableProperty AutoSizeProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
BackgroundColorProperty
Indicates the readonly property.
Declaration
public static readonly BindableProperty BackgroundColorProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ContentHeightRequestProperty
Indicates the ContentHeight property.
Declaration
public static readonly BindableProperty ContentHeightRequestProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
CursorPositionProperty
Indicates the CursorPosition property.
Declaration
public static readonly BindableProperty CursorPositionProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
DefaultFontColorProperty
Indicates the default Font Color property.
Declaration
public static readonly BindableProperty DefaultFontColorProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
DefaultFontProperty
Identifies the DefaultFont bindable property.
Declaration
public static readonly BindableProperty DefaultFontProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
DefaultFontSizeProperty
Indicates the default Font Size property.
Declaration
public static readonly BindableProperty DefaultFontSizeProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
EnableSystemKeyboardProperty
Indicates then EnableSystemKeyboard Property.
Declaration
public static readonly BindableProperty EnableSystemKeyboardProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
EnterKeyProperty
Indicates EnterKey Property.
Declaration
public static readonly BindableProperty EnterKeyProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
FontButtonCommandProperty
Identifies the FontButtonCommand bindable property.
Declaration
public static readonly BindableProperty FontButtonCommandProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
HtmlTextProperty
Indicates the html value property.
Declaration
public static readonly BindableProperty HtmlTextProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ImageInsertCommandProperty
Identifies the ImageInsertCommand bindable property.
Declaration
public static readonly BindableProperty ImageInsertCommandProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
MaximumHeightRequestProperty
Indicates the MaximumHeightRequest property.
Declaration
public static readonly BindableProperty MaximumHeightRequestProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
MinimumHeightRequestProperty
Indicates the MinimumHeightRequest property.
Declaration
public static readonly BindableProperty MinimumHeightRequestProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
PaddingProperty
Indicates the ContentPadding Property.
Declaration
public static readonly BindableProperty PaddingProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
PlaceHolderFontColorProperty
Indicates the place holder font color property.
Declaration
public static readonly BindableProperty PlaceHolderFontColorProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
PlaceHolderFontFamilyProperty
Indicates the place holder font family property.
Declaration
public static readonly BindableProperty PlaceHolderFontFamilyProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
PlaceHolderFontSizeProperty
Indicates the place holder font size property.
Declaration
public static readonly BindableProperty PlaceHolderFontSizeProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
PlaceHolderProperty
Indicates the place holder property.
Declaration
public static readonly BindableProperty PlaceHolderProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ReadOnlyProperty
Indicates the readonly property.
Declaration
public static readonly BindableProperty ReadOnlyProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ScrollOrientationProperty
Indicates the AllowScroll property.
Declaration
public static readonly BindableProperty ScrollOrientationProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ShowToolbarProperty
Indicates the ShowToolar property.
Declaration
public static readonly BindableProperty ShowToolbarProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
StyleSheetTypeProperty
Indicates StyleSheetType Property.
Declaration
public static readonly BindableProperty StyleSheetTypeProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
TextProperty
Indicates the value property.
Declaration
public static readonly BindableProperty TextProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ToolbarItemsProperty
Indicates the toolbar items property.
Declaration
public static readonly BindableProperty ToolbarItemsProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ToolbarOptionsProperty
Indicates the ToolbarOptions property.
Declaration
public static readonly BindableProperty ToolbarOptionsProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ToolbarPositionProperty
Indicates the toolbar position.
Declaration
public static readonly BindableProperty ToolbarPositionProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ToolbarSettingsProperty
Indicates the ToolbarSettings property.
Declaration
public static readonly BindableProperty ToolbarSettingsProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
WordWrapProperty
Indicates the WordWrap property.
Declaration
public static readonly BindableProperty WordWrapProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Properties
AutoSize
Gets or sets a value that controls whether the Rich Text Editor will change size to accommodate input as the user enters it.
Declaration
public AutoSizeOption AutoSize { get; set; }
Property Value
Type |
---|
AutoSizeOption |
Remarks
Automatic resizing is turned off by default.
BackgroundColor
Gets or Sets the value of Background color.
Declaration
public Color BackgroundColor { get; set; }
Property Value
Type |
---|
Xamarin.Forms.Color |
Content
Gets the content of the ContentView.
Declaration
public View Content { get; }
Property Value
Type |
---|
Xamarin.Forms.View |
ContentHeightRequest
Gets the height of the rendered content in the rich text editor.
Declaration
public double ContentHeightRequest { get; }
Property Value
Type |
---|
System.Double |
Remarks
The unit of the height is pixels.
CursorPosition
Gets or sets the position of the cursor based on the characters count in the editor.
Declaration
public int CursorPosition { get; set; }
Property Value
Type |
---|
System.Int32 |
Remarks
Set cursor position will not work in iOS , due to focus limitation.
DefaultFont
Gets or sets the default font.
Declaration
public string DefaultFont { get; set; }
Property Value
Type |
---|
System.String |
Remarks
This default font can be given as Embedded source, System Font Name or Base64 TTF string.
DefaultFontColor
Gets or sets the value for default Font Color.
Declaration
public Color DefaultFontColor { get; set; }
Property Value
Type |
---|
Xamarin.Forms.Color |
DefaultFontSize
Gets or sets the value for default Font Size.
Declaration
public double DefaultFontSize { get; set; }
Property Value
Type |
---|
System.Double |
EnableSystemKeyboard
Gets and sets a value indicates whether to disable or enable the system keypad. The default value is true.
Declaration
public bool EnableSystemKeyboard { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
It only works in Android and iOS platform and not supported in UWP.
EnterKey
Gets or sets the HTML tag to be inserted on "Enter key" press.
Declaration
public EnterKey EnterKey { get; set; }
Property Value
Type |
---|
EnterKey |
Remarks
It only works in iOS and not supported in Android and UWP platform.
FontButtonCommand
Gets or sets the font button command. Triggers while font button in toolbar is clicked.
Declaration
public ICommand FontButtonCommand { get; set; }
Property Value
Type |
---|
System.Windows.Input.ICommand |
HtmlText
Gets or Sets the html value of RichTextEditor.
Declaration
public string HtmlText { get; set; }
Property Value
Type |
---|
System.String |
ImageInsertCommand
Gets or sets the insert image command. Triggers while image button in toolbar is clicked.
Declaration
public ICommand ImageInsertCommand { get; set; }
Property Value
Type |
---|
System.Windows.Input.ICommand |
IsFocused
Gets a value indicating whether RichText editor is focused or not.
Declaration
public bool IsFocused { get; }
Property Value
Type |
---|
System.Boolean |
MaximumHeightRequest
Gets or sets the value which overrides the maximum height the Rich Text Editor will request during layout.
Declaration
public double MaximumHeightRequest { get; set; }
Property Value
Type |
---|
System.Double |
MinimumHeightRequest
Gets or sets the value which overrides the minimum height the Rich Text Editor will request during layout.
Declaration
public double MinimumHeightRequest { get; set; }
Property Value
Type |
---|
System.Double |
Padding
Gets or sets content padding for the control.
Declaration
public Thickness Padding { get; set; }
Property Value
Type |
---|
Xamarin.Forms.Thickness |
PlaceHolder
Gets or sets the value for place holder.
Declaration
public string PlaceHolder { get; set; }
Property Value
Type |
---|
System.String |
PlaceHolderFontColor
Gets or sets the value for place holder font color.
Declaration
public Color PlaceHolderFontColor { get; set; }
Property Value
Type |
---|
Xamarin.Forms.Color |
PlaceHolderFontFamily
Gets or sets the value for place holder font family.
Declaration
public string PlaceHolderFontFamily { get; set; }
Property Value
Type |
---|
System.String |
PlaceHolderFontSize
Gets or sets the value for place holder font size.
Declaration
public double PlaceHolderFontSize { get; set; }
Property Value
Type |
---|
System.Double |
ReadOnly
Gets or Sets a value indicating whether it is readonly or read and write.
Declaration
public bool ReadOnly { get; set; }
Property Value
Type |
---|
System.Boolean |
ScrollOrientation
Gets or sets a value indicating whether rich text edtior to scroll within the editor or to scroll in scroll layout.
Declaration
public ScrollOrientation ScrollOrientation { get; set; }
Property Value
Type | Description |
---|---|
ScrollOrientation | The default value is Vertical. |
Remarks
ScrollOrientation applicable to android only. Since iOS and UWP doesn't have the limiation in scroll view. Rich text editor can scroll either in scroll layout or within the control but not both due to the webview limitation.
ShowToolbar
Gets or Sets a value indicating whether to show or hidden the toolbar of RichTextEditor.
Declaration
public bool ShowToolbar { get; set; }
Property Value
Type |
---|
System.Boolean |
StyleSheetType
Gets or sets the stylesheet type to load the resources needed for the internal web view control. By default, it loads the WebView resources through an external style sheet.
Declaration
public StyleSheetType StyleSheetType { get; set; }
Property Value
Type |
---|
StyleSheetType |
Remarks
It only works in UWP and not supported in Android and iOS platform.
Text
Gets or Sets the value of RichTextEditor.
Declaration
public string Text { get; set; }
Property Value
Type |
---|
System.String |
ToolbarItems
Gets or Sets the toolbar items.
Declaration
public ObservableCollection<object> ToolbarItems { get; set; }
Property Value
Type |
---|
System.Collections.ObjectModel.ObservableCollection<System.Object> |
ToolbarOptions
Gets or sets the customized toolbar items in toolbar.
Declaration
public ToolbarOptions ToolbarOptions { get; set; }
Property Value
Type |
---|
ToolbarOptions |
ToolbarPosition
Gets or sets the value that indicates the position of toolbar.
Declaration
public ToolbarPosition ToolbarPosition { get; set; }
Property Value
Type |
---|
ToolbarPosition |
ToolbarSettings
Gets or Sets the value of RichTextEditor.
Declaration
public ToolbarSettings ToolbarSettings { get; set; }
Property Value
Type |
---|
ToolbarSettings |
WordWrap
Gets or sets the word-wrap that allows long words to be able to be broken and wrap onto the next line.
Declaration
public WordWrap WordWrap { get; set; }
Property Value
Type |
---|
WordWrap |
Methods
AlignCenter()
Aligns the paragraph to center.
Declaration
public void AlignCenter()
AlignFull()
Justifies the paragraph.
Declaration
public void AlignFull()
AlignLeft()
Aligns the paragraph to left.
Declaration
public void AlignLeft()
AlignRight()
Aligns the paragraph to right.
Declaration
public void AlignRight()
ApplyFont(String)
Applies the specified font.
Declaration
public void ApplyFont(string fontName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fontName | font name. |
Remarks
Font need to be set using SetFont(String, Stream) before applying the font.
ClearFormat()
Clears all the format in the selection.
Declaration
public void ClearFormat()
DecreaseIndent()
Decrease the Indent.
Declaration
public void DecreaseIndent()
EditHyperlink(String, String)
Edits the hyperlink.
Declaration
public void EditHyperlink(string url, string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | url link to insert. |
System.String | text | Display text. |
Focus()
Focus the richtext editor for android and UWP.
Declaration
public void Focus()
GetHtmlString()
Returns the html string.
Declaration
public string GetHtmlString()
Returns
Type | Description |
---|---|
System.String | returns html string. |
GetRawString()
Returns the raw string.
Declaration
public string GetRawString()
Returns
Type | Description |
---|---|
System.String | returns raw string. |
GetSelectedText()
Returns the selected text.
Declaration
public string GetSelectedText()
Returns
Type | Description |
---|---|
System.String | returns selected text. |
IncreaseIndent()
Increase the Indent.
Declaration
public void IncreaseIndent()
InsertHTMLText(String)
Inserts the specified text into the SfRichTextEditor.
Declaration
public void InsertHTMLText(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text to be inserted. |
InsertHyperlink(String, String)
Inserts the hyperlink.
Declaration
public void InsertHyperlink(string url, string displayText)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | url link to insert. |
System.String | displayText | Display text. |
InsertImage(ImageSource)
Inserts the specified image into the SfRichTextEditor.
Declaration
public void InsertImage(ImageSource imageSource)
Parameters
Type | Name | Description |
---|---|---|
ImageSource | imageSource | Image to be inserted. |
MoveCursorToEnd()
Moves the cursor position to the end of the content.
Declaration
public void MoveCursorToEnd()
MoveCursorToStart()
Moves the cursor position to the beginning of the content.
Declaration
public void MoveCursorToStart()
OnMeasure(Double, Double)
Triggers this override method when the height changes.
Declaration
protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
Parameters
Type | Name | Description |
---|---|---|
System.Double | widthConstraint | Width constraints. |
System.Double | heightConstraint | Height constraints. |
Returns
Type | Description |
---|---|
Xamarin.Forms.SizeRequest | Returns the new size. |
OnPropertyChanged(String)
This method is called when the bound property is changed.
Declaration
protected override void OnPropertyChanged(string propertyName = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | property name. |
OnSizeAllocated(Double, Double)
Triggers this override method when the size of the element is set during layout cycle.
Declaration
protected override void OnSizeAllocated(double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | width | Width. |
System.Double | height | Height. |
Redo()
Redo the undo actions for UWP.
Declaration
public void Redo()
RemoveHyperlink()
Removes the hyperlink.
Declaration
public void RemoveHyperlink()
SetDefaultFont(String, Stream)
Sets default font in the Rich Text Editor with the specified font name and font stream.
Declaration
public void SetDefaultFont(string fontName, Stream fontStream)
Parameters
Type | Name | Description |
---|---|---|
System.String | fontName | font name. |
System.IO.Stream | fontStream | font stream should be TTF stream. |
SetFont(String, Stream)
Sets font in the Rich Text Editor with the specified font name and font stream.
Declaration
public void SetFont(string fontName, Stream fontStream)
Parameters
Type | Name | Description |
---|---|---|
System.String | fontName | font name. |
System.IO.Stream | fontStream | font stream should be TTF stream. |
SetFontColor(String)
Sets the font color.
Declaration
public void SetFontColor(string fontColor)
Parameters
Type | Name | Description |
---|---|---|
System.String | fontColor | color for font color. |
SetFontSize(String)
Sets the font size.
Declaration
public void SetFontSize(string fontSize)
Parameters
Type | Name | Description |
---|---|---|
System.String | fontSize | Size of the font. |
SetHighlightColor(String)
Highlights the background color.
Declaration
public void SetHighlightColor(string color)
Parameters
Type | Name | Description |
---|---|---|
System.String | color | Color for back color. |
SetParagraphFormat(String)
Sets the paragraph format ( h1,h2,h3,h4,p,Quotation,Code).
Declaration
public void SetParagraphFormat(string heading)
Parameters
Type | Name | Description |
---|---|---|
System.String | heading | Heading style. |
ToggleBold()
Toggles the bold format.
Declaration
public void ToggleBold()
ToggleBulletList()
Toggles the bullet list format.
Declaration
public void ToggleBulletList()
ToggleItalic()
Toggles the Italic format.
Declaration
public void ToggleItalic()
ToggleNumberedList()
Toggles the Numbered list format.
Declaration
public void ToggleNumberedList()
ToggleStrikethrough()
Toggles the strikethrough format.
Declaration
public void ToggleStrikethrough()
ToggleSubScript()
Toggles the selected text as sub script format.
Declaration
public void ToggleSubScript()
ToggleSuperScript()
Toggles the selected text as super script format.
Declaration
public void ToggleSuperScript()
ToggleUnderline()
Toogles the underline format.
Declaration
public void ToggleUnderline()
Undo()
Undo the actions for UWP.
Declaration
public void Undo()
Unfocus()
Unfocuses the richtext editor for android and UWP.
Declaration
public void Unfocus()
Events
Focused
Triggers when the RTE is focused.
Declaration
public event EventHandler<EventArgs> Focused
Event Type
Type |
---|
System.EventHandler<System.EventArgs> |
FontButtonClicked
Font family event occurs when font button in toolbar is clicked.
Declaration
public event EventHandler<FontButtonClickedEventArgs> FontButtonClicked
Event Type
Type |
---|
System.EventHandler<FontButtonClickedEventArgs> |
FormatChanged
The format change event occurs when format is changed in editor.
Declaration
public event EventHandler<FormatChangedEventArgs> FormatChanged
Event Type
Type |
---|
System.EventHandler<FormatChangedEventArgs> |
HyperlinkSelected
The hyperlink selected event occurs when a selected text contains hyperlink.
Declaration
public event EventHandler<HyperlinkSelectedEventArgs> HyperlinkSelected
Event Type
Type |
---|
System.EventHandler<HyperlinkSelectedEventArgs> |
ImageInserted
Image inserted event occurs when image button in toolbar is clicked.
Declaration
public event EventHandler<ImageInsertedEventArgs> ImageInserted
Event Type
Type |
---|
System.EventHandler<ImageInsertedEventArgs> |
TextChanged
The text change event occurs when a text is changed in editor.
Declaration
public event EventHandler<TextChangedEventArgs> TextChanged
Event Type
Type |
---|
System.EventHandler<TextChangedEventArgs> |
Unfocused
Triggers when the RTE is unfocused.
Declaration
public event EventHandler<EventArgs> Unfocused
Event Type
Type |
---|
System.EventHandler<System.EventArgs> |