ParagraphStyle.LinkedStyle Property
Gets or sets the linked style for the current style.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v24.2.Core.dll
NuGet Package: DevExpress.RichEdit.Core
#Declaration
CharacterStyle LinkedStyle { get; set; }
#Property Value
Type | Description |
---|---|
Character |
A Paragraph |
#Remarks
A linked style can act as a paragraph style or a character style, depending on the range to which it is applied.
If a linked style is applied to a selection which does not include an entire paragraph, the selected text is formatted with the character formatting settings of the linked styles.
If a selection includes an entire paragraph, both character and paragraph formatting settings are applied.
If a selection is just a caret position and contains no characters, the linked style behaves like a paragraph style.
You should specify the LinkedStyle property only once, for one of the linked styles.
Note
Assigning a style via the Linked
The code sample below demonstrates how to synchronize a paragraph and character style to create a linked style.
ParagraphStyle annotationStyle = document.ParagraphStyles["Annotation"];
document.BeginUpdate();
//Create a new paragraph style
//and set the required settings
annotationStyle = document.ParagraphStyles.CreateNew();
annotationStyle.Name = "Annotation";
annotationStyle.Alignment = ParagraphAlignment.Right;
annotationStyle.LineSpacingMultiplier = 1.5f;
annotationStyle.FirstLineIndentType = ParagraphFirstLineIndent.Hanging;
annotationStyle.FirstLineIndent = 3;
document.ParagraphStyles.Add(annotationStyle);
//Create a new character style and link it
//to the custom paragraph style
CharacterStyle annotationCharStyle = document.CharacterStyles.CreateNew();
annotationCharStyle.Name = "AnnotationChar";
document.CharacterStyles.Add(annotationCharStyle);
annotationCharStyle.LinkedStyle = annotationStyle;
//Specify the style options
annotationCharStyle.Italic = true;
annotationCharStyle.FontSize = 12;
annotationCharStyle.FontName = "Segoe UI";
annotationCharStyle.ForeColor = Color.Gray;
document.EndUpdate();
//Apply the created style to the first paragraph of the annotation
document.Paragraphs[1].Style = annotationStyle;
//Apply the linked style to the range of the annotation's second paragraph
CharacterProperties annotationProperties = document.BeginUpdateCharacters(document.Paragraphs[2].Range);
annotationProperties.Style = annotationCharStyle;
document.EndUpdateCharacters(annotationProperties);
The image below illustrates the result of the code execution.