


Here, a RichTextBlock targets a RichTextBlockOverflow element to create a multi-column text layout. Run2.Text = " demonstrate some properties" Run2.Foreground = new SolidColorBrush(Windows.UI.Colors.Red) Run.Foreground = new SolidColorBrush(Windows.UI.Colors.Blue) This example shows a RichTextBlock with customization of FontWeight, FontFamily, FontStyle, Foreground, and SelectionHighlightColor for different runs of text. Add the Run to the Paragraph, the Paragraph to the RichTextBlock. Run.Text = "This is some sample text to demonstrate some properties." RichTextBlock.FontFamily = new FontFamily("Arial") RichTextBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.Blue) RichTextBlock.SelectionHighlightColor = new SolidColorBrush(Windows.UI.Colors.Pink) This is some sample text to demonstrate some properties. This example shows a RichTextBlock with customization of FontWeight, FontFamily, FontStyle, Foreground, and SelectionHighlightColor for a single run of text. Add the RichTextBlock to the visual tree (assumes stackPanel is decalred in XAML). Run.Text = "This is some sample text to show the wrapping behavior." RichTextBlock.TextWrapping = TextWrapping.Wrap RichTextBlock.IsTextSelectionEnabled = true Customize some properties on the RichTextBlock. RichTextBlock richTextBlock = new RichTextBlock() Create a RichTextBlock, a Paragraph and a Run. This is some sample text to show the wrapping behavior. Then, add each Paragraph to the RichTextBlock.Blocks collection. In code, you have to explicitly create each Run element, set its Text property, and add it to the Paragraph.Inlines collection. In XAML, the creation of content elements is implicit, so you can add the text directly to the Paragraph element, and the Paragraph directly to the RichTextBlock element. This example shows a RichTextBlock with text selection and text wrapping enabled.
Usp pro rich text editor in form code#
Get the app from the Microsoft Store or get the source code on GitHub. The WinUI 2 Gallery app includes interactive examples of most WinUI 2 controls, features, and functionality. Open the WinUI 2 Gallery app and see the RichTextBlock in action Public sealed class RichTextBlock : FrameworkElement Public NotInheritable Class RichTextBlock Public sealed class RichTextBlock : FrameworkElement / Ĭlass RichTextBlock final : FrameworkElement /// Ĭlass RichTextBlock final : FrameworkElement public ref class RichTextBlock sealed : FrameworkElement /// RichTextBlock supports a built-in overflow model. Represents a rich text display container that supports formatted text, hyperlinks, inline images, and other rich content.
