本文介绍了在Windows应用商店的RichEditBox中插入列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基于RichEditBox控件为Windows应用商店(WinRT)开发文本编辑器.RichEditBox将ITextParagraphFormat用于段落操作,将ListAlignment,ListLevelIndex和其他属性用于项目符号列表和编号列表.我没有找到任何将项目符号或编号列表插入RichEditBox的示例.如何使用ITextParagraphFormat将列表添加到RichEditBox?

I develop text editor for the Windows store application (WinRT) based on RichEditBox control. RichEditBox use ITextParagraphFormat for paragraph operation and ListAlignment, ListLevelIndex and other properties for bulleted and numbered lists.I not found any samples to insert bulleted or numbered lists to RichEditBox. How I can to add lists to RichEditBox using ITextParagraphFormat?

推荐答案

您需要设置 ITextParagraphFormat.ListType 属性.对于项目符号,将ListType属性设置为MarkerType.Bullet,对于数字,将ListType设置为MarkerType.Arabic.更多类型请参考 MarkerType 枚举以选择所需的其他列表类型.

You need to set the ITextParagraphFormat.ListType property for the ITextParagraphFormat. For bullet, set the ListType property to MarkerType.Bullet, for number, set the ListType to MarkerType.Arabic. More types please reference the MarkerType enumeration to choose other list types you want.

这里是有关将项目符号和编号添加到可以测试的RichEditBox中的选定段落列表中的示例.

Here is a sample about adding the bullet and number to the selected paragraph list in the RichEditBox you can test.

XAML代码

 <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>

后面的代码

 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;           
 }

这篇关于在Windows应用商店的RichEditBox中插入列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 20:11