您需要設置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;',一切正常。 –