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&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?
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);
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.