在WPF-FlowDocument中使用MarkerStyle = Disc的列表

时间:2010-06-29 12:43:41

标签: c# wpf flowdocument

我正在尝试在FlowDocument中显示fiew列表。我意识到使用时 MarkerStyle = TextMarkerStyle.Disc,列表与其他列表相比缩进更少。我正在寻找一种方法来显示带有Disc-Markers的列表但与其他标记相同的缩进,任何提示?

下面是一个显示我问题的片段:

        List l = new List();
        l.MarkerStyle = TextMarkerStyle.Disc;    
        l.ListItems.Add(new ListItem(new Paragraph(new Run("cxyc"))));
        l.ListItems.Add(new ListItem(new Paragraph(new Run("asdasd"))));
        l.ListItems.Add(new ListItem(new Paragraph(new Run("ghjtd"))));
        richTextBox.Document.Blocks.Add(l);


        l = new List();
        l.MarkerStyle = TextMarkerStyle.Decimal;
        l.ListItems.Add(new ListItem(new Paragraph(new Run("$!"))));
        l.ListItems.Add(new ListItem(new Paragraph(new Run("&!§"))));
        l.ListItems.Add(new ListItem(new Paragraph(new Run("&!"))));
        richTextBox.Document.Blocks.Add(l);

        l = new List();
        l.MarkerStyle = TextMarkerStyle.LowerLatin;
        l.ListItems.Add(new ListItem(new Paragraph(new Run("16123"))));
        l.ListItems.Add(new ListItem(new Paragraph(new Run("gasd"))));
        l.ListItems.Add(new ListItem(new Paragraph(new Run("612312"))));
        richTextBox.Document.Blocks.Add(l);

        l = new List();
        l.MarkerStyle = TextMarkerStyle.None;
        l.ListItems.Add(new ListItem(new Paragraph(new Run("15123"))));
        l.ListItems.Add(new ListItem(new Paragraph(new Run("fasdas"))));
        l.ListItems.Add(new ListItem(new Paragraph(new Run("5161234"))));
        richTextBox.Document.Blocks.Add(l);

1 个答案:

答案 0 :(得分:3)

将列表上的Padding设置为显式左填充。对于所有四个方向,默认值为Auto(NaN),List将在Autoer时基于MarkerStyle设置左边距。

l.Padding = new Thickness(20, double.NaN, double.NaN, double.NaN);