您需要设置ITextParagraphFormat的ITextParagraphFormat.ListType属性。对于项目符号,将ListType属性设置为MarkerType.Bullet
,对于编号,将ListType设置为MarkerType.Arabic
。更多的类型请参考MarkerType枚举来选择你想要的其他列表类型。
下面是一个关于将项目符号和编号添加到您可以测试的RichEditBox中的选定段落列表的示例。
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;
}
代码就解决了吗? –
是的。谢谢。我为编号列表添加'paragraphFormatting1.ListStart = 1;',一切正常。 –