1

I want to insert an Image inside my Polygon, possibly at the center of the Polygon. Is it possible? How can I do?

Nick
  • 10,309
  • 21
  • 97
  • 201

2 Answers2

4

You can use ImageBrush as the polygon's Fill. Like this:

<Polygon.Fill>
    <ImageBrush ImageSource="sampleImages\berries.jpg"
                AlignmentX="..." AlignmentY="..." />
</Polygon.Fill>
Ilmo Euro
  • 4,925
  • 1
  • 27
  • 29
  • Thanks, but I don't want to change the Polygon Fill. – Nick Jun 26 '12 at 10:27
  • Then you can clip the image with a `PolygonGeometry`. See [Cropping or Clipping in WPF](http://www.c-sharpcorner.com/uploadfile/raj1979/cropping-or-clipping-in-wpf/). For help with centering, see http://stackoverflow.com/questions/2208992/how-to-center-an-element-in-wpf-canvas – Ilmo Euro Jun 26 '12 at 11:00
  • [Here](https://skydrive.live.com/redir?resid=A61D8C70C8903DDC!4937)'s an example. – Ilmo Euro Jun 26 '12 at 16:46
0

May be "Points" attribute help you :

<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>
Niki Nikpour
  • 211
  • 2
  • 4