8

I am creating a simple app to display multiple images one below the other. In WPF, I used Number of canvas equivalent to number of images and added those canvas to the main canvas. And using Image control in each canvas, i uploaded the images with me and it is looking good.

Now, I Am trying to do the same in Windows forms. I tried Panel (as the main canvas in WPF) and draw images over it by using Panel_Paint event. it is fine. But I need to add something(as I added multiple canvas in WPF), but did not get strike any thing. I planned for few panels, but all them need Panel_Paint to draw images over it.That is some what difficult to maintain... any other ideas?

Uthistran Selvaraj.
  • 558
  • 2
  • 11
  • 29
  • 1
    If your WPF code translates well enough to winforms, most probably you're doing it wrong. winforms' databindings capabilities are really limited compared to WPF's. Post your current XAML and code for the WPF version. – Federico Berasategui Aug 08 '13 at 12:55

2 Answers2

5

You can create your own custom control and override OnPaint method. There you will be able to draw whatever you like in Canvas like mode. Create element specify its coordinates, draw it with Graphics object. And for overlaying use linear drawing order, items drawn later will be top most.

VidasV
  • 4,335
  • 1
  • 28
  • 50
2

If you want to create a Paint-like canvas, where you can draw simple graphics and images, you could use an instance of Graphics, like the following:

// myPictureBox is the control where your graphics will be drawn
Graphics myCanvas = myPictureBox.CreateGraphics();

If you want to display a group of images, like .jpg are displayed in the files explorer, you could use a ListView.

Gark Garcia
  • 450
  • 6
  • 14