5

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?

H.B.
  • 166,899
  • 29
  • 327
  • 400
Scott Baker
  • 10,013
  • 17
  • 56
  • 102

2 Answers2

2

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);
}
Eugene Berdnikov
  • 2,150
  • 2
  • 23
  • 30
2

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.

Community
  • 1
  • 1
Amaury Levé
  • 1,459
  • 10
  • 21