Paste List into RichEditBox for Windows Storage Application

I am creating a text editor for a Windows storage application (WinRT) based on a RichEditBox control. RichEditBox uses ITextParagraphFormat for paragraph operations and ListAlignment, ListLevelIndex and other properties for bulleted and numbered lists. I did not find any patterns for inserting bulleted or numbered lists into RichEditBox. How can I add lists to a RichEditBox using ITextParagraphFormat?

0
source share
1 answer

You need to set the ITextParagraphFormat.ListType property for ITextParagraphFormat. For the bullet, set the ListType property to MarkerType.Bullet , for the number, set the ListType parameter to MarkerType.Arabic . For more information, see the MarkerType section to select other types of lists that you want.

Here is an example of adding a bullet and a number to a selected paragraph list in a RichEditBox that you can check.

XAML Code

  <RichEditBox x:Name="Richbox" Height="400" Margin="40" > </RichEditBox> <Button x:Name="BtnSetbullet" Content="set bullet to richeditbox" Click="BtnSetbullet_Click"></Button> <Button x:Name="BtnSetNumber" Content="set number to richeditbox" Click="BtnSetNumber_Click"></Button> 

Code for

  private void BtnSetbullet_Click(object sender, RoutedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = Richbox.Document.Selection; ITextParagraphFormat paragraphFormatting = selectedText.ParagraphFormat; paragraphFormatting.ListType = MarkerType.Bullet; selectedText.ParagraphFormat = paragraphFormatting; } private void BtnSetNumber_Click(object sender, RoutedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = Richbox.Document.Selection; ITextParagraphFormat paragraphFormatting = selectedText.ParagraphFormat; paragraphFormatting.ListType = MarkerType.Arabic; selectedText.ParagraphFormat = paragraphFormatting; } 
0
source

Source: https://habr.com/ru/post/1266502/


All Articles