Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image Renders in Win8/Win10 but not Win7

I have the following XAML in my document:

<Border HorizontalAlignment="Right" VerticalAlignment="Bottom"
        Height="100" Width="100"
        BorderBrush="Red" BorderThickness="2">
    <Image x:Name="image"
           Source="http://myinternalserver/mywebservice/getimage.aspx?id=1234&amp;ContentType=Image" />
</Border>

The image shows up fine in Win10 and Win8, but in Win7 all I get is a red border with a transparent background and no image inside. When I use a static URL, like to the google logo, it renders in all versions.

Anyone have any idea how I can make the image render in Windows 7?

like image 931
Scott Baker Avatar asked Aug 12 '16 19:08

Scott Baker


2 Answers

According to this post WebUrl can't be specified as the Source of a BitmapImage. I recommend to you to make a helper class instead of doing so in the code-behind of the view. Also I would freeze the created image for performance.

like image 157
Amaury Levé Avatar answered Oct 27 '22 01:10

Amaury Levé


Try to check possible exception by subscribing on the Image.ImageFailed event from the code-behind file:

public MainWindow()
{
    InitializeComponent();
    image.ImageFailed += ImageFailed;
}

private void ImageFailed(object sender, ExceptionRoutedEventArgs e)
{
    Console.WriteLine(e.ErrorException);
}
like image 30
Eugene Berdnikov Avatar answered Oct 27 '22 02:10

Eugene Berdnikov