Please, tell me, how can I place the image inside in the middle? Stretch: Uniform to fill. I want to focus was on the middle of the picture
Asked
Active
Viewed 137 times
0
-
Could you give some more information? The middle of what Grid? StackPanel? – Ertay Shashko May 23 '14 at 23:02
-
@ErtayShashko [example](https://www.dropbox.com/s/0ywd2703snkk50j/Screenshot%202014-05-24%2003.22.25.png) – Nikita May 23 '14 at 23:23
-
In this case, some code is worth a thousand words... – BradleyDotNET May 24 '14 at 02:40
-
So you want to crop the middle 20x20 section of the image, even if it is much larger/not square? – Rowland Shaw Jul 26 '14 at 08:10
3 Answers
1
Why dont you Try setting your Image control set Stretch =Fill
<Image height="20" width="20" Stretch="Fill"/>
-
1Most of the times, this is a bad idea, especially if the source does not have the same aspect ratio as the image control. – Ertay Shashko May 23 '14 at 23:48
0
If the aspect ratio of the image you want to put inside an Image control is not 1:1 and you set the aspect ratio of your Image control to 1:1 (e.g. Width="20" and Height="20" you will have a deformed image.
So, the best approach is, set the Width="20" but don't set the Height, let it calculate that automatically. Then, set Stretch="Uniform" (not uniform to fill). It should display the image correctly.
Hope this helps.

Ertay Shashko
- 1,247
- 2
- 12
- 21
0
You can wrap the image inside a Border and set the HorizontalAlignment and VerticalAlignment attributes of your image to 'Center'.

Minh Thai
- 568
- 6
- 18