Text Formatting Using HyperlinkAdv in WPF RichTextBoxAdv (Classic)
5 May 20212 minutes to read
HyperlinkAdv can be kept only inside the ParagraphAdv since the content property of ParagraphAdv is Inline. It allows you to display the formatted text using advanced features like NavigationUrl and TargetType. It simply differs by these properties when compared to SpanAdv.
Properties
Property | Description | Type | Data Type |
---|---|---|---|
Text | Contains the text information. | Dependency Property | String |
Baseline | Indicates whether the inline text is subscript or superscript. | Dependency Property | Baseline |
NavigateURL | Holds the URL to which the page navigates to. | Dependency Property | String |
TargetType | Indicates whether to open the link in the same window or in a new window. | Dependency Property | HyperlinkTargetType |
FontFamily | Specifies the font family of the text. | Dependency Property | FontFamily |
FontSize | Specifies the size of the font. | Dependency Property | Double |
Foreground | Designates the font color. | Dependency Property | Color |
HighlightColor | Designates the highlight color of the text. | Dependency Property | Color |
Strikethrough | Shows whether the text has SingleStrikeThrough or DoubleStrikeThrough. | Dependency Property | StrikeThrough |
FontWeight | Indicates the font weight of the text. | Dependency Property | FontWeight |
Underline | Indicates whether the text should be underlined. | Dependency Property | Underline |
Add HyperlinkAdv to an Application
HyperlinkAdv can be added directly to an application by using the following code snippet:
<syncfusion:RichTextBoxAdv Height="300" Width="400" x:Name="richtext">
<syncfusion:DocumentAdv>
<syncfusion:SectionAdv>
<syncfusion:ParagraphAdv>
<syncfusion:HyperlinkAdv Text="This is Hyperlink text"/>
</syncfusion:ParagraphAdv>
</syncfusion:SectionAdv>
</syncfusion:DocumentAdv>
</syncfusion:RichTextBoxAdv>
RichTextBoxAdv richtext = new RichTextBoxAdv();
DocumentAdv document = new DocumentAdv();
SectionAdv section = new SectionAdv();
ParagraphAdv paragraph = new ParagraphAdv();
HyperlinkAdv hyperlink = new HyperlinkAdv();
hyperlink.Text = "This is Hyperlink text";
paragraph.Inlines.Add(hyperlink);
section.Blocks.Add(paragraph);
document.Sections.Add(section);
richtext.Document = document;