【发布时间】:2011-08-16 18:33:46
【问题描述】:
谢谢。
此问题与此处未回答的旧问题非常相似: How to paint notebook-like lines as TextBox background? 但是,它不一样 - 不完全一样。
我想创建一个记事本,衬纸般的背景,但我不熟悉如何在 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如何解决对齐问题的注释)
标签: wpf background repeat brush