I have a World ( a PictureBox and a Bitmap with is size ( rows * columns ) and create Graphics from Bitmap in Windows Forms ) the following is the code,
bmp = new Bitmap(columns*32, rows*32);
graphics = Graphics.FromImage(bmp);
pictureBox1.Size = new Size(columns * 32, rows * 32);
pictureBox1.Image = bmp;
this i use to populate the Graphics in Windows form,
private void drawImageInBox(Image src, int boxX, int boxY, int Offset = 0)
{
graphics.DrawImage(src, new Point((boxY * 32) + Offset, (boxX * 32) + Offset));
}
and when all operations are done i just refresh the PictureBox,
pictureBox1.Refresh();
how do i achieve this in Silverlight xaml?
You’ll want something like this:
In your XAML:
In your codebehind:
A very important note: every time you “refresh” your “world”, make sure you remove the appropriate images before re-adding them! Better yet, you can just keep track of these images in some array, and change their rows/columns. And if you need to, you can set the visibility on images to hidden/collapsed.