Handling size of image after orientation change WP

2019-05-28 17:37发布

问题:

I've got an Image with an overlay Canvas with some rectangles whose position is relative to image's size. The problem comes when I change the phone orientation, because image size changes (or at least, the renderization) but I can't manage to re-distribute the rectangles according to the new size, and the OrientationChanged event doesn't help me because it's fired before rendering the image (so all the rectangles go to (0,0))

Anyone can help me finding the correct event?

回答1:

I'd either not use percentage widths or save them as exact values when first rendered/measured for one orientation. You can then adjust the dimensions relative to the orientation.

Update
If you can't get the exact values passed to you then you coudl load the image where teh user can't see it to measure it.

If you're getting the image and positions from an external source which always assumes a portrait orientation then why not just always display it as such in your app.



回答2:

Finally got it!

The event I was looking for was the SizeChanged, I can't imagine how I didn't see it before...