谢谢您。
这个问题与这里的一个古老、未回答的问题非常相似:如何在文本框背景上绘制类似笔记本线条的线条?然而,它并不完全一样。
我想创建一个记事本,有像纸张一样的背景,但我不熟悉如何在XAML中重复使用画刷。您该怎么做?
编辑
以下是作为TextBox的解决方案:
<TextBox TextBlock.LineHeight="20"
TextBlock.LineStackingStrategy="BlockLineHeight"
Padding="20,10,20,20" TextWrapping="Wrap">
<TextBox.Background>
<DrawingBrush TileMode="Tile" Stretch="None" Viewport="0,0,20,20"
ViewportUnits="Absolute" Opacity=".07">
<DrawingBrush.Drawing>
<GeometryDrawing>
<GeometryDrawing.Pen>
<Pen Brush="RoyalBlue" />
</GeometryDrawing.Pen>
<GeometryDrawing.Geometry>
<LineGeometry StartPoint="0,0" EndPoint="20,0"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
</TextBox.Background>
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
</TextBox>
LineHeight
和LineStackingStrategy
如何解决对齐问题的说明) - H.B.