2012-06-26 30 views

回答

4

您可以使用ImageBrush作为多边形的Fill。就像这样:

<Polygon.Fill> 
    <ImageBrush ImageSource="sampleImages\berries.jpg" 
       AlignmentX="..." AlignmentY="..." /> 
</Polygon.Fill> 
+0

谢谢,但我不想改变多边形填充。 – Nick

+0

然后,您可以使用“PolygonGeometry”剪辑图像。参见[在WPF中裁剪或裁剪](http://www.c-sharpcorner.com/uploadfile/raj1979/cropping-or-clipping-in-wpf/)。有关集中的帮助,请参阅http://stackoverflow.com/questions/2208992/how-to-center-an-element-in-wpf-canvas –

+0

您可以告诉我如何用示例剪辑图像? – Nick

0

可能是“点”属性帮助您:

<Polygon Points="40,0 150,100 10,100" > 
    <Polygon.Fill> 
     <ImageBrush ImageSource="C:\Users\Public\Pictures\Sample Pictures\Penguins.jpg" Stretch="Uniform" AlignmentX="Left" /> 
    </Polygon.Fill> 
</Polygon>