Search code examples
c#wpfflowdocument

Lists with MarkerStyle = Disc in a WPF-FlowDocument


I'm trying to display a fiew lists in a FlowDocument. I Realized that when using MarkerStyle = TextMarkerStyle.Disc, the list gets less indentation then with the others. Im looking for a way to display lists with Disc-Markers but the same indentation as the other markers get, any hints?

Heres a snippet that shows my problem :

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

Solution

  • Set the Padding on the List to have an explicit left padding. The default is Auto (NaN) for all four directions, and List will set the left padding based on the MarkerStyle when it is Auto.

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