Другим решением является заимствование этой функции indent
для использования с библиотекой ElementTree, встроенной в Python с 2,5. Вот как это выглядит:
from xml.etree import ElementTree
def indent(elem, level=0):
i = "\n" + level*" "
j = "\n" + (level-1)*" "
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + " "
if not elem.tail or not elem.tail.strip():
elem.tail = i
for subelem in elem:
indent(subelem, level+1)
if not elem.tail or not elem.tail.strip():
elem.tail = j
else:
if level and (not elem.tail or not elem.tail.strip()):
elem.tail = j
return elem
root = ElementTree.parse('/tmp/xmlfile').getroot()
indent(root)
ElementTree.dump(root)
Я сделал это со стилем (расположенная с отступом игра слов)
<RichTextBox Margin="0,51,0,0" Name="mainTextBox" >
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
Близко, таким образом, Вы поняли мысли. На самом деле это оказалось установкой поля,
p.Margin = new Thickness(0);
Используя высоту строки
RichTextBox rtb = new RichTextBox();
Paragraph p = rtb.Document.Blocks.FirstBlock as Paragraph;
p.LineHeight = 10;
<RichTextBox Height="250" Width="500" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" IsReadOnly="True" >
<Paragraph>
XYZ
<LineBreak />
</Paragraph>
</RichTextBox>