Getting the height of an ImageSource in Silverlight

徘徊边缘 提交于 2019-12-13 03:06:59

问题


In my Silverlight control, I am loading my background image from a stream:

   BitmapImage img = new BitmapImage();
   img.SetSource(stream);

   Image background = new Image();
   background.Source = img;

How can I find out the height of the bitmap image that was loaded from stream? None of the usual suspects (e.g., Property, DependencyProperty) seem to be available, neither on img, nor on background.


回答1:


I would try:

img.Measure();
img.DesiredSize.Height;


来源:https://stackoverflow.com/questions/966696/getting-the-height-of-an-imagesource-in-silverlight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!