Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set an image background to repeat?

I'm trying to set an image background to repeat along my entire grid. It's a small image, with a bit of random noise in to give it texture.

Currently this is what I'm doing:

<Grid.Background>
    <ImageBrush ImageSource="Images/mainBg.png" Stretch="UniformToFill" />
</Grid.Background>

But this blows up the image and makes the noise look terrible. I'd like to have the image repeat itself on the X and Y axis to fill the space it can.

Is this possible?

like image 571
Only Bolivian Here Avatar asked May 25 '11 21:05

Only Bolivian Here


1 Answers

Short answer:
There is no way to create tiles of images on the phone.

Long answer:
You shouldn't even try this on the phone. As(suming) you know the image you want to tile at design time you should create a larger image which includes the tiled effect at design time. This will reduce the amount of work your app needs to do, allowing it to run faster.

If you really must do this at run time. You could add a number if images inside a WrapPanel (from the Silverlight Toolkit). You may want to experiment with setting the source of each image from code behind to the same in memory instance of the image to save resources/memory. (This is just a thought - Test it! - it may not even be an issue.)

like image 157
Matt Lacey Avatar answered Sep 30 '22 14:09

Matt Lacey