và cảm ơn bạn.Lặp lại cọ nền trong WPF
Câu hỏi này rất giống với câu hỏi cũ chưa được trả lời ở đây: How to paint notebook-like lines as TextBox background? Tuy nhiên, nó không giống nhau - không chính xác.
Tôi muốn tạo một notepad, lót giấy giống như nền nhưng tôi không quen thuộc với cách lặp lại một bàn chải trong XAML. Làm thế nào bạn?
EDIT
Dưới đây là các giải pháp như là một phần của một 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>
Về chỉnh sửa đề nghị: Tôi sẽ đồng ý, xin vui lòng trích xuất giải pháp cụ thể của bạn thành một câu trả lời riêng biệt. (Cũng có thể thêm một lưu ý về cách 'LineHeight' và' LineStackingStrategy' giải quyết vấn đề căn chỉnh, nếu cần) –