图像渲染Win8 / Win10但不是Win7

时间:2016-08-12 19:35:44

标签: c# wpf xaml windows-7

我的文档中有以下XAML:

<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>

图像在Win10和Win8中显示得很好,但在Win7中,我得到的是一个带有透明背景且内部没有图像的红色边框。当我使用静态网址时,就像谷歌徽标一样,它会在所有版本中呈现。

任何人都知道如何在Windows 7中制作图像?

2 个答案:

答案 0 :(得分:2)

尝试通过从代码隐藏文件中订阅Image.ImageFailed事件来检查可能的异常:

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

private void ImageFailed(object sender, ExceptionRoutedEventArgs e)
{
    Console.WriteLine(e.ErrorException);
}

答案 1 :(得分:2)

根据this post,WebUrl不能被指定为BitmapImage的源。我建议你创建一个帮助类,而不是在视图的代码隐藏中这样做。此外,我会冻结创建的图像以提高性能。

相关问题