1、WPF使用画像画刷(ImageBrush)
<Grid>
<Grid.Background>
<ImageBrush ImageSource="1.png"
Stretch="None"
TileMode="Tile"
ViewportUnits="Absolute">
<ImageBrush.Viewport>
<Rect X="0" Y="0" Width="20" Height="20"/>
</ImageBrush.Viewport>
</ImageBrush>
</Grid.Background>
</Grid>
具体可阅读:TileBrush 概述 - WPF .NET Framework | Microsoft Learn
2、WPF使用DrawingBrush画刷
<Grid>
<Grid.Background>
<DrawingBrush Stretch="Fill" TileMode="Tile"
Viewport="0,0,20,20" ViewportUnits="Absolute" >
<DrawingBrush.Drawing>
<GeometryDrawing Brush="#333333" Geometry="M0,2 L1,2 1,3 0,3 Z M1,1 L2,1 2,2 1,2 z"/>
</DrawingBrush.Drawing>
</DrawingBrush>
</Grid.Background>
</Grid>
具体可阅读:DrawingBrush 类 (System.Windows.Media) | Microsoft Learn
效果图如下: