How to display rectangles on an image, and drag-and-drop them? #17907
Replies: 2 comments 5 replies
-
This Avalonia desktop app' of mine does Drag and Drop of controls: Most "interesting" area: Hope this helps... |
Beta Was this translation helpful? Give feedback.
-
I'm still struggling to display an image scaled to the Window. If my Window.axaml contains this:
Then the image is displayed, but not scaled to fit the window (it's just displayed as-is, and since it is larger than the screen, it runs off both the right and bottom edges). The rectangle is displayed correctly (on the unscaled image). If I wrap that in a There's clearly some boat I am missing here... |
Beta Was this translation helpful? Give feedback.
-
I am trying to port an old WinForms application to Avalonia; it displays an image (which is scaled to fit the window), and on which are some number of rectangles. The user needs to be able to move and resize the rectangles using both the mouse and the keyboard.
In Ye Olde Days, I would handle the "mouse down" event, capture the mouse, and then handle the "mouse moved" events to implement the drag and drop. The screen coordinates are converted to image coordinates by scaling them the same amount the image was scaled to fit the window.
I can easily display the image and scale it to fit the window; however, I am at a loss as to how to position the rectangles, and also how to implement drag-and-drop.
This is an MVVM application (since that is what the client already has some familiarity with). I've tried using the Canvas control to contain the image and the rectangles; however I can't seem to get the image scaled to fit the window in this case. Nor have I stumbled on how to drag-and-drop the rectangles.
Any pointers to get me started in the right direction would be warmly welcomed.
TIA,
--mkj
Beta Was this translation helpful? Give feedback.
All reactions