How to get the height of an Image in Silverlight?
Posted
by Edward Tanguay
on Stack Overflow
See other posts from Stack Overflow
or by Edward Tanguay
Published on 2010-03-20T15:50:51Z
Indexed on
2010/03/20
16:01 UTC
Read the original article
Hit count: 239
I have this code in Silverlight:
Image image = new Image();
BitmapImage bitmapImage= TheDatasourceManager.GetBitmapImage("blackPencil");
image.Source = bitmapImage;
image.Stretch = Stretch.None;
image.HorizontalAlignment = HorizontalAlignment.Left;
image.VerticalAlignment = VerticalAlignment.Top;
image.Margin = new Thickness(88, 88, 0, 0);
grid.Children.Add(image);
Now I want to find out the height of the image.
- in WPF I can get it with image.Source.Height but this is not available in Silverlight
- bitmapImage.Height doesn't exist either
- when I debug and examine the image object, I eventually get to PixelHeight which has an accurate height, but I can't seem to access it
- I find image.ActualHeight but it is 0.
How can I get the height of the image?
© Stack Overflow or respective owner