layout - How to keep relative position of WPF elements on background image -
I'm new to WPF, so the answer to the following question may be obvious, although this is not for me Image is required to display where users can set markers (as an example: you want to mark a person's face on a photo with a rectangle), although marking the images in their relative position Need of It is possible.
Currently I am using a canvas and setting an ImageBrush as the background. This image displays and I can add elements like a label (as a rectangle replacement) at the top of the image but when I set a label like this, its position is complete And therefore when the underlying picture is minimized (because the user maximizes the window) Label remains rather than its full position (say, 100,100), the difference of which to move to a new position Is stocked with inherent "image" in sync.
To make this case short: When I set a marker on a person's eyes, then it should not be on the person's ear after scaling the window.
Any suggestions about how to do this in WPF? Maybe the canvas is the wrong approach in the first place? I can keep a collection of markers in the code and every time I re-calculate their position in the window's resize, but I hope WPF let me do this work: -)
I'm interested in hearing your feedback on this
In the top of my head you write a converter class Which can take one percent and a full position as an example if your window 200 x 200 And you put the label in 100 x 100, when you scale the window for 400 x 400, the label will stay where it is (according to your basic question). However, if you have used the converter, instead you can set the label to 50% of the size of its original container, as if the small label from the window will proceed with it.
You may also need to use it converter for width and height so that it also increases in size.
Sorry for the lack of detail, if I get the chance I will edit it with the example code in a while.
Edit to add
Returns some code for one percent converter.
Comments
Post a Comment