我使用path来创建自定义对象:
<Path Style="{StaticResource ABC_Style}" ToolTip="object ABC" HorizontalAlignment="Center" VerticalAlignment="Center"></Path>
ABC_Style定义是:
<Style x:Key="ABC_Style" TargetType="Path">
<Setter ..../>
<Setter Property="Fill" Value .../>
</Style>
现在,我必须将网格图像分配给对象(作为内容)。
问题:
感谢。
答案 0 :(得分:1)
我能想到的是,您可以创建类似
的绘图画笔 <ImageBrush ImageSource="image.jpg" x:Key="imageBrush" />
<DrawingBrush x:Key="ThatchBackground" Viewport="0,0,50,50" ViewportUnits="Absolute" Stretch="None" TileMode="Tile">
<DrawingBrush.Drawing>
<GeometryDrawing Brush="{StaticResource imageBrush}">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0,0,50,50"/>
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
并设置路径填充如下
<Path Fill="{StaticResource ThatchBackground}">
我从本教程http://wpfplayground.blogspot.com/2011/09/texture-background-in-wpf.html
中得到了这个