views:

16

answers:

1

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?

A: 

I finally found it, it's just bitmapImage.PixelHeight. Since I'm not stretching it, seems to work fine.

Edward Tanguay