Is it good practice to position UIElements via Ren

2019-08-17 07:59发布

问题:

In my WPF application I have a control that acts like a zoom box. You can zoom and drag its content. In my case this content is a grid that contains an image and some UserControls. These UserControls have to be positioned ontop of the image to highlight some segments of that image.

Here is an example (this is not an actual use case):

My question is, how should I position those red rectangles (what is the better practise here)?

  1. By replacing the grid with a canvas and use Canvas.SetLeft resp. Canvas.SetTop?

or

  1. By manipulating the RenderTransform of those rectangles?

Note: The rectangles are interactive (they have to interact with the mouse and maybe some other input devices).