Reputation: 455
My problem is I have paths to draw cities and I want to put images inside these cities I cant put Image inside <Path>
tags.
Why cant I write such code? any solution?
Upvotes: 0
Views: 585
Reputation: 18118
Use a canvas or a custom panel with x,y placements and add images to the correct coordinates (same coordinates used by path).
You can query the path nodes to find their coordinates if you don't know them.
Edit: Since your window size changes and coordinates "stretch" accordingly, you will need to implement a custom panel. - Inherit from Panel and override measure and arrange methods as in this example: http://www.wpftutorial.net/CustomLayoutPanel.html
Your custom panel should have X and Y attached dependency properties (like Canvas does) only that methods should use either relative coordinates (0 to 1) instead of (0 to width and 0 to height) or divide by original path width and height to normalize to coordinates.
Upvotes: 1
Reputation: 185290
You can use the Path.Fill
for this. Use an ImageBrush
.
On a side-note, what can be written as child node/s of a element is determined by the ContentPropertyAttribute
, for a ContentControl
it points to the Content
property for example (as can be seen in the Syntax
section of its documentation).
Upvotes: 2