图像显示不正常

时间:2014-07-31 13:34:32

标签: c# wpf

enter image description here 所以使用snoop我可以看到属性如下

Image 1
Height = 160
ActualHeight = 160
Width = 372
ActualWidth = 299.7468...
x = 0
y = 0

image 2
Height = 50
ActualHeight = 26.6891...
Width = 50
ActualWidth = 50 
x = 20
y = 20


Image 2
Height = 50
ActualHeight = 26.6891...
Width = 50
ActualWidth = 50 
x = 60
y = 60

所以我的问题是如何让ActualHeight和ActualWidth始终等于高度和宽度?另外,为什么图像1看起来不会放在画布上的0,0上?

1 个答案:

答案 0 :(得分:1)

为了确保ActualWidthActualHeight等于WidthHeight(假设它们实际已设置),您应该设置图像&#39 ; Stretch属性为Fill

<Image ... Width="50" Height="50" Stretch="Fill"/>