views:

54

answers:

1

Hi

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);
+1  A: 

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);
Quartermeister
Thanks! Are you sure you dont Mean l.Margin? This will compensate for the lesser indentation lists with Disc-Markers get, but anyway, i don't understand why there is less indentation to lists with Circles then to any other, and I'm not entirely sure that this "static" solution will work with different Fonts etc.
Robert J.
@Robert: I do mean Padding. When Padding.Left is set to Auto, WPF will calculate the padding based on the marker style. It seems to do this a little differently for each marker style, which is why you see the variable indentation. If you set it to a a fixed number, it won't use that calculation and the indentation will be the same for any marker style.
Quartermeister
Ah i see, i just added it to the first list and that didnt give me good results, Padding is exactly what I needed, Thanks a lot!
Robert J.