0

enter image description here

How can I wrap an image around the canvas like this? The obvious way I can think of is to duplicate the image, and offset by the width/height of the image in the opposite direction. Is there another way to achieve this?

Deniz Cetinalp
  • 901
  • 1
  • 18
  • 34

2 Answers2

1

No. There is no other way around. You will have to draw all images. Because a control doesn't split up.

You can calculate and then generate Image boxes to show no. of images based on offset.

Shaharyar
  • 12,254
  • 4
  • 46
  • 66
  • Is there a simple way to check if an image is touching the border? Those that are will be duplicated and translated appropriately. Or will I have to duplicate every single image, even those that don't touch the edges? – Deniz Cetinalp Aug 16 '14 at 08:00
  • No you can check for the border image. get the size of image, and subtract it from the size of form. Its a simple logic. Have a loot at this answer too http://stackoverflow.com/questions/16303726/wpf-image-panning-constraints – Shaharyar Aug 16 '14 at 08:13
1

You could fill a Rectangle with an ImageBrush with this image, and set its TileMode and Viewport properties as needed.

For example:

<Rectangle Width="128" Height="128">
    <Rectangle.Fill>
        <ImageBrush ImageSource="Images\Tile.png" TileMode="Tile"
                    ViewportUnits="Absolute" Viewport="64,64,128,128"/>
    </Rectangle.Fill>
</Rectangle>

The above XAML creates the following output:

enter image description here

from this source image:

enter image description here

Clemens
  • 123,504
  • 12
  • 155
  • 268