views:

989

answers:

2

Is there a way to get the original image size in terms of width and height of a png image that is loaded in an image control?

A: 

How about - in your code behind file (.xaml.cs) reload the image into a new image control and take the width and height from that?

Something like this:

System.Windows.Controls.Image img = new System.Windows.Controls.Image();
string UriValue = HtmlPage.Document.DocumentUri.AbsoluteUri + imagefilename;
img.SetValue(System.Windows.Controls.Image.SourceProperty, 
        new System.Windows.Media.Imaging.BitmapImage(new Uri(UriValue)));
double imagewidth = img.Width;
BPerreault
Tried that but doesnt find the sizes straight away
Drahcir
A: 

I have downloaded silverlight 3 beta which provides the event ImageOpened which has arguments that can show the actual image dimentions

Drahcir