I am trying to get a TextRange from a WPF FlowDocument ListItem:
var doc = new FlowDocument();
doc.Blocks.Add(new List(new ListItem(new Paragraph(new Run("first bullet")))));
If I now try to get a TextRange with
var range1 = new TextRange(doc.ContentStart, doc.ContentEnd);
or
var range2 = new TextRange(doc.ContentStart.GetNextInsertionPosition(LogicalDirection.Forward), doc.ContentEnd);
I get a range where the Text property returns
• first bullet
And if I try
var range3 = new TextRange(doc.ContentStart.GetNextInsertionPosition(LogicalDirection.Forward).GetNextInsertionPosition(LogicalDirection.Forward), doc.ContentEnd);
the Text property returns
irst bullet
The debugger shows:
range1.Start.Offset == 4
range2.Start.Offset == 4
range3.Start.Offset == 5
How could I create a TextRange which points to "first bullet" only (without the bullet and the separating tab)?