本文介绍了重复在WPF背景刷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
和谢谢你。
这问题很相似,这个古老的,悬而未决的问题在这里:
How ?油漆笔记本状线作为文本框背景的然而,这是不一样的。 - 不完全
我想创建一个记事本,横格纸般的背景,但我不是不熟悉如何在XAML重复刷。你怎么了?
修改
下面是解决方案作为一个TextBox的一部分:
<文本框TextBlock.LineHeight =20
TextBlock.LineStackingStrategy =BlockLineHeight
填充=20,10,20,20TextWrapping =自动换行>
< TextBox.Background>
< DrawingBrush TILEMODE =平铺拉伸=无视=0,0,20,20
ViewportUnits =绝对不透明度=&GT07。
< DrawingBrush.Drawing>
< GeometryDrawing>
< GeometryDrawing.Pen>
<笔刷=红深蓝/>
< /GeometryDrawing.Pen>
< GeometryDrawing.Geometry>
< LineGeometry StartPoint可以=0,0终点=20.0/>
< /GeometryDrawing.Geometry>
< / GeometryDrawing>
< /DrawingBrush.Drawing>
< / DrawingBrush>
< /TextBox.Background>
现在是时候让所有的好男人来到他们的国家的援助。
现在是时候让所有的好男人来到他们的国家的援助。
现在是时候让所有的好男人来到他们的国家的援助。
现在是时候让所有的好男人来到他们的国家的援助。
现在是时候让所有的好男人来到他们的国家的援助。
< /文本框>
解决方案
< DrawingBrush TILEMODE =平铺拉伸=无
视=0,0,20,20ViewportUnits =绝对>
< DrawingBrush.Drawing>
< GeometryDrawing>
< GeometryDrawing.Pen>
<笔刷=灰色/>
< /GeometryDrawing.Pen>
< GeometryDrawing.Geometry>
< LineGeometry StartPoint可以=0,0
终点=20.0/>
< /GeometryDrawing.Geometry>
< / GeometryDrawing>
< /DrawingBrush.Drawing>
< / DrawingBrush>
and thank you.
This question is very similar to this old, unanswered question here:How to paint notebook-like lines as TextBox background? However, it is not the same - not exactly.
I would like to create a notepad, lined paper-like background but I am not not familiar with how to repeat a brush in XAML. How do you?
EDIT
Here's the solution as part of a 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>
解决方案
<DrawingBrush TileMode="Tile" Stretch="None"
Viewport="0,0,20,20" ViewportUnits="Absolute">
<DrawingBrush.Drawing>
<GeometryDrawing>
<GeometryDrawing.Pen>
<Pen Brush="Gray"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Geometry>
<LineGeometry StartPoint="0,0"
EndPoint="20,0"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
这篇关于重复在WPF背景刷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!