Can I get the Height and Width of an Image, if it has been Stretched by UniformToFill?
I tried Width and Height properties but they are always NaN.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to know the dimensions of the image control, this is the way:
(
imgis the image control name in the code above, and in the codes below)And if you want to know actual size of image (before it being stretched) you may try this:
(I’ve Found this here)
Also this will get you the dimensions of image after resizing (But before uniforming):
So, one of those variables (
actWidthoractHeight) must be equal to image control dimension, and the other will be higher than it.Please note that the second and the third codes are not working if you call them in
Window_Loadedevent, since images are not loaded at that moment. You should use it after everything is loaded.